1
votes

While my application runs a brief animation, I don't want the user to be able to click on anything. In my view controller I can use

    self.view.userInteractionEnabled = NO;

to block most interaction, but it doesn't prevent the buttons in the toolbar/navbar from firing events.

I can't just disable the buttons, since this has a distracting visual impact (the buttons are grayed out).

How might I briefly suspend interaction with ALL of the controls?

1

1 Answers

12
votes

Use -beginIgnoringInteractionEvents and -endIgnoringInteractionEvents on your instance of UIApplication. This is exactly what classes like UINavigationController do when animating a push to a new view controller. To get your particular instance of UIApplication, use the +sharedApplication method on the UIApplication class. Consider this example.

[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
[[UIApplication sharedApplication] endIgnoringInteractionEvents];