IOS device slide events

Source: Internet
Author: User

IOS device slide events

As long as you touch the screen, slide, and exit from the screen, the system will generate events of the UIEvent object type-of course, including UITouch events-touchesBegan: withEvent: Call method-touchesMoved when the user touches the screen: withEvent: This method is called when the user touches and moves the screen-touchesEnded: withEvent: This method is called when the touch leaves the screen

-TouchesCancelled: withEvent: This method is called when the touch is canceled.

Example:

Cpp Code
  1. // Slide start event
  2. -(Void) touchesBegan :( NSSet *) touches withEvent :( UIEvent *) event
  3. {
  4. UITouch * touch = [touches anyObject];
  5. CGPoint pointone = [touch locationInView: self. view]; // obtain the initial contact point.
  6. Self. startPoint = pointone;
  7. }
  8. // Sliding move event
  9. -(Void) touchesMoved :( NSSet *) touches withEvent :( UIEvent *) event
  10. {
  11. UITouch * touch = [touches anyObject];
  12. // ImgViewTop is the last View to be touched after sliding
  13. CGPoint pointtwo = [touch locationInView: imgViewTop]; // obtain the last point that contacts the screen after sliding.
  14. If (fabs (pointtwo. x-startPoint.x)> 100)
  15. {// Determine the distance between two points
  16. BMove = YES;
  17. }
  18. }
  19. // Event handling by sliding end
  20. -(Void) touchesEnded :( NSSet *) touches withEvent :( UIEvent *) event
  21. {
  22. UITouch * touch = [touches anyObject];
  23. CGPoint pointtwo = [touch locationInView: self. view]; // obtain the last point that contacts the screen after sliding.
  24. If (fabs (pointtwo. x-startPoint.x)> 50) & (bMove ))
  25. {
  26. // Determine the positional relationship between points and move left
  27. If (pointtwo. x-startPoint.x> 0)
  28. {// Left slide Service Processing
  29. If (clicks> 0 ){
  30. Clicks --;
  31. If ([wyKPI. sortZbs count]> 1 ){
  32. [BtnRight setEnabled: YES];
  33. If (clicks = 0)
  34. {
  35. [BtnLeft setEnabled: NO];
  36. [BtnRight setEnabled: YES];
  37. }
  38. [LabTitle setText: [wyKPI. sortZbs objectAtIndex :( NSUInteger) clicks];
  39. [LabTitle setFont: [UIFont systemFontOfSize: 14.0f];
  40. [TabWyKPI reloadData];
  41. }
  42. }
  43. }
  44. // Determine the positional relationship of a vertex and slide right
  45. Else
  46. {// Right-sliding Service Processing
  47. If (clicks <[wyKPI. sortZbs count]-1 ){
  48. Clicks ++;
  49. If ([wyKPI. sortZbs count]> 1 ){
  50. [BtnLeft setEnabled: YES];
  51. If (clicks = [wyKPI. sortZbs count]-1)
  52. {
  53. [BtnLeft setEnabled: YES];
  54. [BtnRight setEnabled: NO];
  55. }
  56. [LabTitle setText: [wyKPI. sortZbs objectAtIndex: clicks];
  57. [LabTitle setFont: [UIFont systemFontOfSize: 14.0f];
  58. [TabWyKPI reloadData];
  59. }
  60. }
  61. }
  62. }
  63. }
// Slide start event-(void) touchesBegan :( NSSet *) touches withEvent :( UIEvent *) event {UITouch * touch = [touches anyObject]; CGPoint pointone = [touch locationInView: self. view]; // obtain the initial contact point self. startPoint = pointone;} // The sliding movement event-(void) touchesMoved :( NSSet *) touches withEvent :( UIEvent *) event {UITouch * touch = [touches anyObject]; // imgViewTop is the final View CGPoint pointtwo = [touch locationInView: imgViewTop] After sliding; // obtain the final point of contact to the screen after sliding if (fabs (pointtwo. x-startPoint.x)> 100) {// determine the distance between two points bMove = YES;} // sliding End Processing Event-(void) touchesEnded :( NSSet *) touches withEvent :( UIEvent *) event {UITouch * touch = [touches anyObject]; CGPoint pointtwo = [touch locationInView: self. view]; // obtain the point if (fabs (pointtwo. x-startPoint.x)> 50) & (bMove) {// judge the positional relationship of the Point left sliding if (pointtwo. x-startPoint.x> 0) {// left slide business processing if (clicks> 0) {clicks --; if ([wyKPI. sortZbs count]> 1) {[btnRight setEnabled: YES]; if (clicks = 0) {[btnLeft setEnabled: NO]; [btnRight setEnabled: YES];} [labTitle setText: [wyKPI. sortZbs objectAtIndex :( NSUInteger) clicks]; [labTitle setFont: [UIFont systemFontOfSize: 14.0f]; [tabWyKPI reloadData];} // determine the positional relationship between points and right sliding else {// right sliding service processing if (clicks <[wyKPI. sortZbs count]-1) {clicks ++; if ([wyKPI. sortZbs count]> 1) {[btnLeft setEnabled: YES]; if (clicks = [wyKPI. sortZbs count]-1) {[btnLeft setEnabled: YES]; [btnRight setEnabled: NO];} [labTitle setText: [wyKPI. sortZbs objectAtIndex: clicks]; [labTitle setFont: [UIFont systemFontOfSize: 14.0f]; [tabWyKPI reloadData] ;}}}

 


Ios704: Unlock your iOS device. Otherwise, you cannot continue the jailbreak process. How can this problem be solved? Slide and unlock, please.

Have you set the password? If the password is set, remove it.

How to restart ios devices

Press the home Key for 3 seconds and slide the slider. After the black screen, press the home Key for 3 seconds.
 

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.