O'Reilly logo

Programming iOS 4 by Matt Neuburg

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Restricting Touches

Touch events can be turned off entirely at the application level with UIApplication’s beginIgnoringInteractionEvents. It is quite common to do this during animations and other lengthy operations during which responding to a touch could cause undesirable results. This call should be balanced by endIgnoringInteractionEvents. Pairs can be nested, in which case interactivity won’t be restored until the outermost endIgnoringInteractionEvents has been reached.

A number of high-level UIView properties also restrict the delivery of touches to particular views:

userInteractionEnabled
If set to NO, this view (along with its subviews) is excluded from receiving touches.
hidden
If set to YES, this view (along with its subviews) is excluded from receiving touches.
opacity
If set to 0.0 (or extremely close to it), this view (along with its subviews) is excluded from receiving touches.
multipleTouchEnabled
If set to NO, this view never receives more than one touch simultaneously; once it receives a touch, it doesn’t receive any other touches until that first touch has ended.
exclusiveTouch
This is the only one of these properties that can’t be set in the nib. An exclusiveTouch view receives a touch only if no other views in the same window have touches associated with them; once an exclusiveTouch view has received a touch, then while that touch exists no other view in the same window receives any touches.

Note

A UIWindow ignores multipleTouchEnabled; it always receives ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required