1. Use of Pat gesture recognizer
UITapGestureRecognizer *tapgesture=[[uitapgesturerecognizer alloc]initwithtarget:self Action: @selector ( Handletapgesture:)];
Set the number of taps to be tapped
tapgesture.numberoftapsrequired=1;
Set the number of touches you want to touch:
tapgesture.numberoftouchesrequired=2;//using Alt
Add gesture recognizer to the view being played
[Aview Addgesturerecognizer:tapgesture];
[Tapgesture release];
2. Create a translation gesture recognizer
Uipangesturerecognizer *pangesture=[[[uipangesturerecognizer alloc]initwithtarget:self Action: @selector ( Handlepangesture:)]autorelease];
[Aview Addgesturerecognizer:pangesture];
3. Create a rotary gesture recognizer
Uirotationgesturerecognizer *rotationgesture=[[uirotationgesturerecognizer alloc]initwithtarget:self action:@ Selector (handlerotationgesture:)];
[Aview Addgesturerecognizer:rotationgesture];
4. Create a zoom gesture recognizer
Uipinchgesturerecognizer *pinchgesture=[[uipinchgesturerecognizer alloc]initwithtarget:self Action: @selector ( Handlepinchgesture:)];
[Aview addgesturerecognizer:pinchgesture];//kneading
tapgesture.delegate=self;
rotationgesture.delegate=self;
pinchgesture.delegate=self;
5. Create a long-press gesture recognizer
Uilongpressgesturerecognizer *longpressgesture=[[[uilongpressgesturerecognizer alloc]initWithTarget:self action:@ Selector (handlelongpressgesture:)]autorelease];
[Aview Addgesturerecognizer:longpressgesture];
longpressgesture.minimumpressduration=0.5;
6. Create a swipe gesture recognizer
Uiswipegesturerecognizer *swipegesture=[[[uiswipegesturerecognizer alloc]initwithtarget:self Action: @selector ( Handleswipegesture:)]autorelease];
[Aview Addgesturerecognizer:swipegesture];
Swipegesture.direction=uiswipegesturerecognizerdirectiondown;
7. Create a screen edge swipe recognizer
Uiscreenedgepangesturerecognizer *screenedgegesture=[[[uiscreenedgepangesturerecognizer Alloc]initWithTarget: Self action: @selector (handlescreenedgegesture:)]autorelease];
[Self.view Addgesturerecognizer:screenedgegesture];
Screenedgegesture.edges=uirectedgeleft;
When a gesture recognizer object is recognized, the proxy object is queried, and the other gesture recognizers are allowed to be recognized at the same time. If this protocol method returns Yes, it means allow. Not allowed by default
-(BOOL) Gesturerecognizer: (Uigesturerecognizer *) Gesturerecognizer Shouldrecognizesimultaneouslywithgesturerecognizer: (Uigesturerecognizer *) othergesturerecognizer{
return YES;
}
-(void) Handlepangesture: (Uipangesturerecognizer *) sender{
UIView *aview=sender.view;
Gets the displacement increment that the gesture produces in the view's corresponding coordinate system
Cgpoint Point=[sender TranslationInView:aView.superview];
Create new deformations based on the last view of the graph
Aview.transform=cgaffinetransformtranslate (Aview.transform, Point.x, POINT.Y);
Zeroing the currently generated increment
[Sender Settranslation:cgpointzero InView:aView.superview];
}
-(void) Handlerotationgesture: (Uirotationgesturerecognizer *) sender{
UIView *aview=sender.view;
Aview.transform=cgaffinetransformrotate (Aview.transform, sender.rotation);
sender.rotation=0;//set the angle increment of rotation to 0;
}
-(void) Handlepinchgesture: (Uipinchgesturerecognizer *) sender{
UIView *aview=sender.view;
Aview.transform=cgaffinetransformscale (Aview.transform, Sender.scale, Sender.scale);
sender.scale=1;
}
Use of gesture Recognizer 111