Search code examples
iphonetouch

How do you disable touch to screen without using beginIgnoringInteractionEvents?


from a similar question/answer

You could always put a transparent UIView over top of the area you want to "disable" tap input for, have it listen for taps, and have it ignore them. Remove the UIView (or hide it) when you want input to be listened to again.

Now, I can understand the strategy, but would someone enlighten me with a code?

How do you make a view
1. listen for taps
2. have it ignore them

Would it not pass touch to views behind it?


Solution

  • Set a plain UIView's userInteractionEnabled property to YES, but don't have any code in there to respond to touch events. The view will then 'swallow' all touches.