iPhone:如何设置清晰的窗口大小“阻止视图”?
我觉得这对我来说应该是显而易见的,但由于某种原因我无法弄清楚。我有一个带有导航栏、工具栏和主视图的导航界面。有时,用户执行的操作会导致视图中间出现进度指示器。
当进度指示器(这是一个自定义 UIView)在中间旋转时,我希望不允许触摸输入进入任何底层界面(主视图、导航栏、工具栏等)。但这似乎并不微不足道。
我尝试(但失败了)创建一个简单的视图,其唯一的工作是吞下触摸输入并将其用作窗口子视图 - 没有骰子,它永远不会获取触摸事件(是的,它确实具有 userInteractionEnabled)。我尝试将其作为透明模态视图控制器固定,但它们似乎从来都不是透明的。
想法?我缺少什么?
谢谢!
I feel like this should be obvious to me, but for some reason I can't figure this out. I have a navigation interface with nav bar, tool bar, and primary view. Sometimes the user takes an action that causes a progress indicator to appear in the middle of the view.
While the progress indicator (which is a custom UIView) in spinning in the middle, I want no touch input to be allowed to go to any of the underlying interface (main view, nav bar, toolbar, etc). But this doesn't seem trivial.
I've tried (and failed) to create a simple view whose only job is to swallow touch input and use it as a window subview-- no dice, it never gets the touch events (and yes, it does have userInteractionEnabled). I've tried to bolt it on as a transparent modal view controller, but those don't seem to ever be transparent.
Thoughts? What am I missing?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以阻止应用程序接受交互事件,
然后再次开始接收事件
,但我会非常小心,因为它会阻止用户与您的应用程序一起交互。
建议另一条路线。您可以显示仅使用 init 方法创建的 UIAlertView,以将进度指示器放置在其中。如果您使用 init 方法,则将没有按钮可供用户交互。然后,当您完成后,您可以关闭警报视图。如果您想为用户提供取消操作的方法,您甚至可以使用警报视图上的按钮来取消操作。
You could stop the applicaiton from accepting interaction events with
And then start taking events again
But I would be extremely careful with that as it stops the user from interacting with your app all together.
To suggest another route. You could display a UIAlertView created with just the init method to house the the progress indicator in the middle of it. If you use the init method than there will be no buttons for the user to interact with. Then when ever you are done you can dismiss the alert view. If you wanted to give the user a way to cancel the action you can even use a button on the alert view to cancel it.
您可以使用
windowLevel
> 创建一个透明的 UIWindow 1.You can create a transparent UIWindow with a
windowLevel
> 1.