IOS using the custom Gesture Mask button workaround/uitapgesturerecognizer Mask button

Source: Internet
Author: User

Sometimes you need to add gestures to the ScrollView to get a click, and then to put the keyboard back on, use the add gesture. However, there will be some follow-up problems, such as intercepting all the other clickable controls on ScrollView, and you may be able to set some properties of the gesture control. But it is not enough to set the properties of Uigesturerecognizer, for example:

screentouch.numberoftapsrequired = 1;

[Screentouchsetcancelstouchesinview:no];

This sometimes intercepts the Uitextfield button that clears the text. At this point, we need the following method to fundamentally handle the gesture response event method.

1, in. h

Add <UIGestureRecognizerDelegate> delegate to the header file

2. Add the implementation method to the. M body file ————

When an event is judged to be a gesture, enter the gesture proxy method first. This method determines whether the clicked view is a button if the button returns no, the gesture does not respond to the event, and it does not cancel the delivery of the event, since it is not responding. The button receives the event and processes it.

#pragma mark-uigesturerecognizerdelegate

-(BOOL) Gesturerecognizer: (Uigesturerecognizer *) Gesturerecognizer Shouldreceivetouch: (Uitouch *) touch

{

Judging is not UIButton class

if ([Touch.view Iskindofclass:[uibutton class]])

{

return NO;

}

Else

{

return YES;

}

}

3, after such a toss, the biggest feeling is that there are solutions to all things, do not give up easily, to more search network resources.

IOS using the custom Gesture Mask button workaround/uitapgesturerecognizer Mask button

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.