Question

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!

Was it helpful?

Solution

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.

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top