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 anexclusiveTouch
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 ...
Get Programming iOS 4 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.