- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. // Rotation Gesture UIRotationGestureRecognizer *rotationGesture =[[UIRotationGestureRecognizer alloc] initWithTarget: self action: @selector(rotationGuestureHandle:)]; [[self view] addGestureRecognizer:rotationGesture]; } -(void) rotationGuestureHandle:(UIRotationGestureRecognizer *) sender { NSLog(@"Rotation Gesture Handling"); }
// // ViewController.h // rotationGesture // // Created by Weerachai on 11/17/55 BE. // Copyright (c) 2555 Weerachai. All rights reserved. // #import <UIKit/UIKit.h> @interface ViewController : UIViewController { IBOutlet UIImageView *imgView; } @end
// // ViewController.m // rotationGesture // // Created by Weerachai on 11/17/55 BE. // Copyright (c) 2555 Weerachai. All rights reserved. // #import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. // Rotation Gesture UIRotationGestureRecognizer *rotationGesture =[[UIRotationGestureRecognizer alloc] initWithTarget: self action: @selector(rotationGuestureHandle:)]; [[self view] addGestureRecognizer:rotationGesture]; } -(void) rotationGuestureHandle:(UIRotationGestureRecognizer *) sender { NSLog(@"Rotation Gesture Handling"); UIRotationGestureRecognizer *rotation = (UIRotationGestureRecognizer *)sender; CGFloat angle = rotation.rotation; imgView.transform = CGAffineTransformRotate(imgView.transform, angle); rotation.rotation=0.0; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (void)dealloc { [imgView release]; [super dealloc]; } @end
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท