Ios gestures are interesting. ios gestures are interesting.

Source: Internet
Author: User

Ios gestures are interesting. ios gestures are interesting.
Ios gestures are very interesting.
I. Overview

For iPhone touch screen processing, before 3.2UIResponderThe following four methods are provided:

-(Void) touchesBegan :( NSSet *) touches withEvent :( UIEvent *) event-(void) touchesCancelled :( NSSet *) touches withEvent :( UIEvent *) event-(void) touchesEnded :( NSSet *) touches withEvent :( UIEvent *) event-(void) touchesMoved :( NSSet *) touches withEvent :( UIEvent *) event

However, it is difficult to identify different gesture operations in this way. You need to calculate different gesture resolutions by yourself. Later...

Apple provides a simple way to useUIGestureRecognizer.

Ii. UIGestureRecognizer

UIGestureRecognizer base classIs an abstract class, We mainlyUse its subclass(The name contains the link. You can click to jump to the ios Developer library to view the official documentation ):

  • UITapGestureRecognizer

  • UIPinchGestureRecognizer

  • UIRotationGestureRecognizer

  • UISwipeGestureRecognizer

  • UIPanGestureRecognizer

  • UILongPressGestureRecognizer

We can know from the name,Tap, Pinch, Rotation, Swipe, and Pan, is used to monitor the amount of offset) and LongPress (long press ).

For example, you can add the following in the viewDidLoad function:


[Cpp]View plaincopy
  1. -(Void) viewDidLoad
  2. {
  3. [Super viewDidLoad];
  4. // Do any additional setup after loading the view from its nib.
  5. UIPanGestureRecognizer * panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget: self action: @ selector (handlePanFrom :)];
  6. [Self. view addGestureRecognizer: panRecognizer]; // key statement, which adds a gesture monitoring to self. view;
  7. PanRecognizer. maximumNumberOfTouches = 1;
  8. PanRecognizer. delegate = self;
  9. [PanRecognizer release];
  10. }

Other gestures are similar.


Its core is to set the delegate and use addGestureRecognizer on the view for gesture monitoring to add the specified gesture monitoring.

Of course, remember to add <UIGestureRecognizerDelegate> to the view header file of the delegate.

But some gestures are associated. What should I do? For example, Tap and LongPress, Swipe and Pan, or Tap twice.

Gesture Recognition is mutually exclusive.,For example, if you click or double-click a gesture to recognize it, the subsequent gesture will not be recognized.. Therefore, for associated gestures, special processing is required to help programs identify the types of gestures that should be attributed to the current gestures.

For example, if you click and double-click to coexist, if you do not process it, it can only send the clicked message. To recognize double-click gestures, you need to make a special processing logic, that is, first determine whether the gesture is double-click. When the double-click fails, it is processed as a click gesture. Use

[A requireGestureRecognizerToFail: B]Function, which specifies that when A gesture occurs, even if A has reached the limit,It will not be triggered immediately.,Will waitThe specified gesture B is triggered only after confirmation of failure.


[Cpp]View plaincopy
  1. -(Void) viewDidLoad
  2. {
  3. // Click Recognizer
  4. UITapGestureRecognizer * singleRecognizer;
  5. SingleRecognizer = [[UITapGestureRecognizer alloc] initWithTarget: selfaction: @ selector (SingleTap :)];
  6. // Number of clicks
  7. SingleTapRecognizer. numberOfTapsRequired = 1; // click
  8. // Add a gesture monitor to self. view;
  9. [Self. view addGestureRecognizer: singleRecognizer];
  10. // Double-click Recognizer
  11. UITapGestureRecognizer * double;
  12. DoubleRecognizer = [[UITapGestureRecognizer alloc] initWithTarget: selfaction: @ selector (DoubleTap :)];
  13. DoubleTapRecognizer. numberOfTapsRequired = 2; // double-click
  14. // Key statement: Add a gesture monitoring to self. view;
  15. [Self. view addGestureRecognizer: doubleRecognizer];
  16. // The key lies in this line. If you double-click the gesture to confirm that the monitoring fails, the corresponding operation of the click gesture will be triggered.
  17. [SingleRecognizer requireGestureRecognizerToFail: doubleRecognizer];
  18. [SingleRecognizer release];
  19. [DoubleRecognizer release];
  20. }
  21. -(Void) SingleTap :( UITapGestureRecognizer *) recognizer
  22. {
  23. // Process the click operation
  24. }
  25. -(Void) DoubleTap :( UITapGestureRecognizer *) recognizer
  26. {
  27. // Process double-click operations
  28. }
Iii. Approximate types of iphone operation gestures

1. Click (Tap) as the most common gesture, used to press or select a control or entry (similar to a common mouse click ),

2. Drag is used to scroll some pages and move controls.

3. Flick is used to implement the function of quickly rolling and turning pages on pages.

4. The sweep gesture is used to activate the shortcut menu of the list items.

5. Double-click (Double Tap) Double-click to enlarge and show the image in the center, or restore the original size (if the current size has been enlarged ). You can also double-click to activate the text editing menu.

6. the Pinch open zoom gesture enables the following functions: open the subscription source and open the details of the article. When you view a photo, you can also use the zoom-In gesture to zoom in the image.

7. The zoom-In gesture function is opposite to the zoom-In gesture and corresponds to the function: Disable the subscription source to exit the home page, and close the article to exit the index page. When you view a photo, the zoom-In gesture can also be used to zoom out the image.

8. On the my subscription page, the long-pressed subscription source automatically enters the editing mode and selects the subscription source currently pressed by the finger. In this case, you can directly drag the position of the subscription source to move. If you press the text in a long way, the magnifier function is displayed. The Edit menu is displayed. The Edit menu is displayed when you press and hold the image.

9. The Shake gesture will show the Undo and redo menu. It is mainly for user text input.

What are the meanings of various gestures in life? For example, extend the middle finger? I have read many images? What do you mean? The more the better the first, the OK gesture. The index finger and the big ring form an "O" type, and the other three fingers are naturally bent. In China, it generally represents "zero" or "three" digits. The United States, which expresses "agree, remarkable, smooth, and appreciated"
Second, he pointed out in China to show that the other party is "nonsense" and despise or insult the other party.
Third, give a thumbs up gesture. Raise your thumb vertically, and hold the other four fingers tightly. The Chinese use this gesture to express praise and appreciation
Fourth, the V gesture. The forefoot and middle finger are erected separately. This gesture is now widely used to represent "victory" (the first letter of Vicente ).
Fifth, stretch the index finger gesture. The index finger stretched out, and the other four fingers naturally clenched. This gesture means "one", "one time", or "reminding the other party to pay attention" in China;
Sixth, other gestures. When talking about a problem, some people adjust the strap on the other hand, play the shirt button on the other hand, or pull the shirt, or play with nearby objects, which indicates that this person is nervous or lying, and his hand is only used to hide it.
7. Waving a hand to China and greeting others.
Eighth, a thumbs up in China is a positive signal, which usually refers to high praise, praise, great, and "boss". A little thumbs up indicates contempt, belittle, and "bad.
Ninth point
It means ridicule and does not believe it. It was originally a gesture used by children, but it is also used by many adults.
The tenth "Attach" gesture indicates that you have nothing to do with something and have nothing to do with it. The specific rubbing method is: first use the left hand palm to rub the right hand back, from the wrist until the fingertip.
11th. First point to yourself, then bend your thumb to hold the middle finger and ring finger, erect both the index finger and the small thumb, and finally point to your lover.
I love you
12th beckoning, waving goodbye, clap praise, thank you, raise your hand to approve, and throw your hand to refuse; the hand is love, the finger is angry, the hand is kiss, the hand is respect, the hand is shy, and so on. The meaning of a gesture, send a message, or express your feelings. The ability to use gestures appropriately to express your emotions and improve your communication image.
13th shake hands with people
At the beginning of the meeting, when you say goodbye to others, send condolences to others, express gratitude, and make a slight apology, you will often hold hands with others. First, pay attention to the sequence. During handshaking, the standard order of the two sides should be "superior first ". That is, the person with a high position reaches out, and the person with a low position reaches out. If you are a service person, do not take the initiative to reach out and contact the service object. It usually takes 3 to 5 seconds to shake hands with a person. Usually, the right hand should be used to communicate with people. It is not suitable for the left hand, and it is not necessary to hold hands with both hands.
14th heads in both hands
Many people like to put one hand or two hands behind their heads. The purpose of this integration is to relax. If you do this in front of others, especially when providing services to others, you will feel like nobody else.
The funny gesture gave a thumbs up and bent twice. Thank you.

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: 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.