//
Viewcontroller.m
zwj-gesture Recognition-zoom and rotate
//
Created by ZWJ on 14-9-16.
Copyright (c) 2014 ZWJ. All rights reserved.
//
#import "ViewController.h"
@interface Viewcontroller () <UIGestureRecognizerDelegate>
@property (Weak, nonatomic) Iboutlet Uiimageview *imgview;
@end
@implementation Viewcontroller
-(void) viewdidload
{
[Super Viewdidload];
[Self testpinchges];
[Self testrotationges];
}
/**
* Test pinch gesture
*/
-(void) testpinchges{
Uipinchgesturerecognizer *pinch = [[Uipinchgesturerecognizer alloc] initwithtarget:self action: @selector (Pincheview :)];
[Self.imgview Addgesturerecognizer:pinch];
Pinch.delegate = self;
}
-(void) Pincheview: (Uipinchgesturerecognizer *) pinch
{
NSLog (@ "%f", Pinch.scale);
Pinch.view.transform = Cgaffinetransformscale (Pinch.view.transform, Pinch.scale, Pinch.scale);
Pinch.scale = 1;
}
/**
* Test Rotation gestures
*/
-(void) testrotationges{
Uirotationgesturerecognizer *rotation = [[Uirotationgesturerecognizer alloc]initwithtarget:self Action: @selector ( Rotationview:)];
[Self.imgview addgesturerecognizer:rotation];
Rotation.delegate = self;
}
-(void) Rotationview: (Uirotationgesturerecognizer *) rotation{
CGFloat rotationf = rotation.rotation;
NSLog (@ "Rotating%f", rotationf);
Rotation.view.transform = Cgaffinetransformrotate (Rotation.view.transform, rotation.rotation);
rotation.rotation = 0;
NSLog (@ "1111---%@", self.view);
NSLog (@ "2222---%@", rotation.view);
}
/**
* Implement Proxy method
*/
-(BOOL) Gesturerecognizer: (Uigesturerecognizer *) Gesturerecognizer Shouldrecognizesimultaneouslywithgesturerecognizer: (Uigesturerecognizer *) othergesturerecognizer{
return YES;
}
@end
iOS gesture recognition-zoom and rotate