IOS-Learning: iOS-disabled Touch events and ios-disabled touch events

Source: Internet
Author: User

[Switch] iOS learning: iOS disables Touch events and ios disables touch events

In iOS apps, there are sometimes requirements to prohibit applications from receiving Touch (for example, when an animation is ongoing, preventing Touch events from triggering new methods ).

I. There are two types:

1. Create a mask layer to prohibit interaction;

2. Use the method in UIApplication to set the interaction as follows:

// Start to disable interaction-(void) beginIgnoringInteractionEvents NS_EXTENSION_UNAVAILABLE_IOS (""); // nested. set shoshould be set during animations & transitions to ignore touch and other events // end disable interaction-(void) endIgnoringInteractionEvents NS_EXTENSION_UNAVAILABLE_IOS (""); // whether interaction is disabled # if UIKIT_DEFINE_AS_PROPERTIES @ property (nonatomic, readonly, getter = isIgnoringInteractionEvents) BOOL ignoringInteractionEvents; // returns YES if we are at least one deep in ignoring events # else-(BOOL) isIgnoringInteractionEvents; // returns YES if we are at least one deep in ignoring events # endif

2. The specific implementation in the Code is as follows:

1. Disable Interaction

If (! [[UIApplication sharedApplication] isIgnoringInteractionEvents]) // disable interaction [[UIApplication sharedApplication] beginIgnoringInteractionEvents];

2. Change from disabled to enabled Interaction

If ([[UIApplication sharedApplication] isIgnoringInteractionEvents]) [[UIApplication sharedApplication] endIgnoringInteractionEvents]; // enable interaction

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.