开发者

iPhone: how do I set up a clear window-size "blocker view"?

开发者 https://www.devze.com 2022-12-23 22:22 出处:网络
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

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 开发者_如何学Csimple 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!


You could stop the applicaiton from accepting interaction events with

[[UIApplication sharedApplication] beginIgnoringInteractionEvents];

And then start taking events again

[[UIApplication sharedApplication] endIgnoringInteractionEvents];

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.


You can create a transparent UIWindow with a windowLevel > 1.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号