Ios gestures are interesting. ios gestures are interesting.
Ios gestures are very interesting.
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.
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 ):
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:
- -(Void) viewDidLoad
- [Super viewDidLoad];
- // Do any additional setup after loading the view from its nib.
- UIPanGestureRecognizer * panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget: self action: @ selector (handlePanFrom :)];
- [Self. view addGestureRecognizer: panRecognizer]; // key statement, which adds a gesture monitoring to self. view;
- PanRecognizer. maximumNumberOfTouches = 1;
- PanRecognizer. delegate = self;
- [PanRecognizer release];
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.
- -(Void) viewDidLoad
- // Click Recognizer
- UITapGestureRecognizer * singleRecognizer;
- SingleRecognizer = [[UITapGestureRecognizer alloc] initWithTarget: selfaction: @ selector (SingleTap :)];
- // Number of clicks
- SingleTapRecognizer. numberOfTapsRequired = 1; // click
- // Add a gesture monitor to self. view;
- [Self. view addGestureRecognizer: singleRecognizer];
- // Double-click Recognizer
- UITapGestureRecognizer * double;
- DoubleRecognizer = [[UITapGestureRecognizer alloc] initWithTarget: selfaction: @ selector (DoubleTap :)];
- DoubleTapRecognizer. numberOfTapsRequired = 2; // double-click
- // Key statement: Add a gesture monitoring to self. view;
- [Self. view addGestureRecognizer: doubleRecognizer];
- // 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.
- [SingleRecognizer requireGestureRecognizerToFail: doubleRecognizer];
- [SingleRecognizer release];
- [DoubleRecognizer release];
- -(Void) SingleTap :( UITapGestureRecognizer *) recognizer
- // Process the click operation
- -(Void) DoubleTap :( UITapGestureRecognizer *) recognizer
- // Process double-click operations
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.
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.