IOS Touch Event distinguishes the method of clicking the double-click Response _ios

Source: Internet
Author: User
Tags touch

If you have a view in your IPhone application, there are both a click and a double-click operation. When a user double-clicks a view, it always performs a click action before double-clicking. Therefore, direct judgement will find that you can not directly into the double-click operation. Here's how to tell if touch events are clicked or double-clicked

-(void) singletap{
NSLog (@ "Tap 1 time");
}
-(void) doubletap{
NSLog (@ "Tap 2 Time");
}
-(void) Touchesbegan: (Nsset *) touches withevent: (Uievent *) event {
Uitouch *touch = [touches anyobject];
Nstimeinterval delaytime = 0.4;//to adjust
switch (touch.tapcount) {case
1:
[self performselector:@ Selector (SINGLETAP) Withobject:nil afterdelay:delaytime];
break;
Case 2:{
[nsobject cancelpreviousperformrequestswithtarget:self selector: @selector (SINGLETAP) Object:nil];
[Self performselector: @selector (DOUBLETAP) Withobject:nil afterdelay:delaytime];
}
break;
Default: Break
;
}
}

The above is a small series to introduce the iOS touch event to distinguish between click and double-click the response method, I hope to help you, if you have any questions welcome to my message, small series will promptly reply to everyone!

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.