IOS development touch and click events: UITapGestureRecognizer and UIPanGestureRecognizer applications

Source: Internet
Author: User

UITapGestureRecognizer and UIPanGestureRecognizer applications:
I. UITapGestureRecognizer application:


-(Void) singleOne :( UITapGestureRecognizer *) sender {} // write the action of the event to the function.

- (void)singleTwo:(UITapGestureRecognizer *)sender { }

- (void)doubleOne:(UITapGestureRecognizer *)sender { }

- (void)doubleTwo:(UITapGestureRecognizer *)sender { }

UITapGestureRecognizer * singleOne = [[UITapGestureRecognizer alloc] initWithTarget: self action: @ selector (singleOne :)];

SingleOne. numberOfTouchesRequired = 1; // The number of touch points. For example, [singleOne setNumberOfTouchesRequired: 1];

SingleOne. numberOfTapsRequired = 1; // Number of clicks, also called: [singleOne setNumberOfTapsRequired: 1];

UITapGestureRecognizer * singleTwo = [[UITapGestureRecognizer alloc] initWithTarget: self action: @ selector (singleTwo :)];

SingleTwo. numberOfTouchesRequired = 2;

SingleTwo. numberOfTapsRequired = 1;

UITapGestureRecognizer * doubleOne = [[UITapGestureRecognizer alloc] initWithTarget: self action: @ selector (doubleOne :)];

DoubleOne. numberOfTouchesRequired = 1;

DoubleOne. numberOfTapsRequired = 2;

UITapGestureRecognizer * doubleTwo = [[UITapGestureRecognizer alloc] initWithTarget: self action: @ selector (doubleTwo :)];

DoubleTwo. numberOfTouchesRequired = 2;

DoubleTwo. numberOfTapsRequired = 2;

[SingleOne requireGestureRecognizerToFail: doubleOne]; // prevent: Double-click to intercept [singleTwo requireGestureRecognizerToFail: doubleTwo]; // prevent: Double-click to intercept

[Self. view addGestureRecognizer: singleOne];

[Self. view addGestureRecognizer: singleTwo];

[Self. view addGestureRecognizer: doubleOne];

[Self. view addGestureRecognizer: doubleTwo];

[SingleOne release];

[SingleTwo release];

[DoubleOne release];

[DoubleTwo release];


UIPanGestureRecognizer post-sharing


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.