How to disable touch events in iOS

There comes the time when your app needs to do something, and while it’s doing that you don’t want the user messing with your interface: no switching to another tab, scrolling around, flicking switches or pressing buttons – because perhaps any of those actions would crash your app.

But how do you do that?

It’s actually super easy – if you know how. UIApplication to the rescue:

// ignore touch events
[[UIApplication sharedApplication]beginIgnoringInteractionEvents];

This will disable all user input for any view that’s currently displayed, application wide. Animating menu items (such as UIActivityIndicators) will remain animating and visible.

When you’re done, simply call the opposite of the above and you’re back in the touch business:

// accept user input again
[[UIApplication sharedApplication]endIgnoringInteractionEvents];




Leave a Reply