How to rotate UIImageView with two fingure touch in iOS SDK..as I know this is very simple but because of I am new in this technology so cant understand...
How to use UIRotationGestureRecognizer to implement this...
Please help me to solve this problem...
Thanks.
Code this on view did load or the imageview create function : m_ctrlImgVwShowImage - your's imageview
UIRotationGestureRecognizer *rotationRecognizer = [[[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotate:)] autorelease];
[rotationRecognizer setDelegate:self];
[m_ctrlImgVwShowImage addGestureRecognizer:rotationRecognizer];
//lastRotation is a cgfloat member variable
-(void)rotate:(id)sender {
if([(UIRotationGestureRecognizer*)sender state] == UIGestureRecognizerStateEnded) {
_lastRotation = 0.0;
return;
}
CGFloat rotation = 0.0 - (_lastRotation - [(UIRotationGestureRecognizer*)sender rotation]);
CGAffineTransform currentTransform = m_ctrlImgVwShowImage.transform;
CGAffineTransform newTransform = CGAffineTransformRotate(currentTransform,rotation);
[m_ctrlImgVwShowImage setTransform:newTransform];
_lastRotation = [(UIRotationGestureRecognizer*)sender rotation];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With