Uigesturerecognizer is an abstract class that defines the basic behavior of all gestures, and it has 6 subclasses that handle specific gestures:
1.UITapGestureRecognizer (any number of clicks on any finger)
Click Count
Numberoftapsrequired
Number of fingers
Numberoftouchesrequired
UITapGestureRecognizer *tapgesturerecognizer = [[UITapGestureRecognizer alloc] init];
[Tapgesturerecognizer addtarget:self Action: @selector (Gesturerecognizerhandle:)];
[Tapgesturerecognizer Setnumberoftapsrequired:2];
[Tapgesturerecognizer Setnumberoftouchesrequired:2];
[Self.view Addgesturerecognizer:tapgesturerecognizer];
2.UIPinchGestureRecognizer (two finger kneading action)
Finger pinch, greater than 1 means that the distance between two fingers becomes larger, less than 1 means that the distance between two fingers is smaller
Scale
Rate (acceleration) of finger pinch action
Velocity
Uipinchgesturerecognizer *pinchgesturerecognizer = [[Uipinchgesturerecognizer alloc] init];
[Pinchgesturerecognizer addtarget:self Action: @selector (Gesturerecognizerhandle:)];
[Self.view Addgesturerecognizer:pinchgesturerecognizer];
3.UIPanGestureRecognizer (shake or drag)
Minimum number of fingers
Minimumnumberoftouches
Maximum number of fingers
Maximumnumberoftouches
Uipangesturerecognizer *pangesturerecognizer = [[Uipangesturerecognizer alloc] init];
[Pangesturerecognizer addtarget:self Action: @selector (Gesturerecognizerhandle:)];
[Pangesturerecognizer setminimumnumberoftouches:1];
[Pangesturerecognizer Setmaximumnumberoftouches:5];
[Self.view Addgesturerecognizer:pangesturerecognizer];
4.UISwipeGestureRecognizer (finger swipe on the screen to manipulate gestures)
Number of sliding fingers
Numberoftouchesrequired
Direction of finger sliding (up,down,left,right)
Direction
Uiswipegesturerecognizer *swipegesturerecognizer = [[Uiswipegesturerecognizer alloc] init];
[Swipegesturerecognizer addtarget:self Action: @selector (Gesturerecognizerhandle:)];
[Swipegesturerecognizer Setnumberoftouchesrequired:2];
[Swipegesturerecognizer Setdirection:uiswipegesturerecognizerdirectionright];
[Self.view Addgesturerecognizer:swipegesturerecognizer];
5.UIRotationGestureRecognizer (finger rotation on the screen)
Rotation direction, less than 0 counterclockwise rotation gesture, greater than 0 for clockwise gestures
Rotation
Rotation rate
Velocity
Uirotationgesturerecognizer *rotationgesturerecognizer = [[Uirotationgesturerecognizer alloc] init];
[Rotationgesturerecognizer addtarget:self Action: @selector (Gesturerecognizerhandle:)];
[Self.view Addgesturerecognizer:rotationgesturerecognizer];
6.UILongPressGestureRecognizer (Long press gesture)
Default is 0. The number of full taps required before the press for gesture to be recognized
Numberoftapsrequired
The number of fingers that need to be pressed long
Numberoftouchesrequired
Time required for long press, Min. 0.5s
Minimumpressduration
The distance the finger presses to allow movement
Allowablemovement
Uilongpressgesturerecognizer *longpressgesturerecognizer = [[Uilongpressgesturerecognizer alloc] init];
[Longpressgesturerecognizer addtarget:self Action: @selector (Gesturerecognizerhandle:)];
[Longpressgesturerecognizer setminimumpressduration:1.0f];
[Longpressgesturerecognizer setallowablemovement:50.0];
[Self.view Addgesturerecognizer:longpressgesturerecognizer];
iOS gesture Uigesturerecognizer