Gesture recognition two for iOS development gesture processing

Source: Internet
Author: User

#import "ViewController.h"@interfaceViewcontroller () <UIGestureRecognizerDelegate>@property (Weak, nonatomic) Iboutlet Uiimageview*Imagev;@end@implementationViewcontroller- (void) viewdidload {[Super viewdidload]; //additional setup after loading the view, typically from a nib.self.imageV.userInteractionEnabled=YES; //Add a rotation gesture[self rotationges]; //Add a pinch gesture[self pinch]; }//simultaneous: At the same time//allow multiple gestures to be supported simultaneously-(BOOL) Gesturerecognizer: (Uigesturerecognizer *) Gesturerecognizer Shouldrecognizesimultaneouslywithgesturerecognizer: (Uigesturerecognizer *) othergesturerecognizer{returnYES;} //Add a rotation gesture- (void) rotationges{//Add a rotation gestureUirotationgesturerecognizer *rotation =[[Uirotationgesturerecognizer alloc] initwithtarget:self action: @selector (rotationges:)]; Rotation.Delegate=Self ; [Self.imagev addgesturerecognizer:rotation];}- (void) Rotationges: (Uirotationgesturerecognizer *) rotationges{Self.imageV.transform=cgaffinetransformrotate (Self.imageV.transform, rotationges.rotation); //Reset[Rotationges setrotation:0]; }  //Add a pinch gesture- (void) pinch{Uipinchgesturerecognizer*pinch =[[Uipinchgesturerecognizer alloc] initwithtarget:self action: @selector (pinch:)]; Pinch.Delegate=Self ; [Self.imagev addgesturerecognizer:pinch];}//called when zooming- (void) Pinch: (Uipinchgesturerecognizer *) pinch{NSLog (@"%s", __func__); Self.imageV.transform=Cgaffinetransformscale (Self.imageV.transform, Pinch.scale,pinch.scale); //Reset[Pinch Setscale:1];}- (void) panges{//Add a drag gestureUipangesturerecognizer *pan =[[Uipangesturerecognizer alloc] initwithtarget:self action: @selector (pan:)]; [Self.imagev Addgesturerecognizer:pan];}//called when a view is dragged- (void) Pan: (Uipangesturerecognizer *) Pan {//gets the offset (relative to the most primitive offset)Cgpoint TRANSP =[Pan TranslationInView:self.imageV]; NSLog (@"%@", Nsstringfromcgpoint (TRANSP)); Self.imageV.transform=cgaffinetransformtranslate (Self.imageV.transform, transp.x, TRANSP.Y); //make it relative to the last time//Reset.[Pan Settranslation:cgpointzero InView:self.imageV]; }@end

Gesture recognition two for iOS development gesture processing

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.