Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rotating a view on touch

I have to rotate a view circularly on finger touch...I mean like dialing the old phones number...and the touch should be only on corners.....can any one help me...i have tried it a lot...but was not successes

enter image description here

like image 586
Kumar sonu Avatar asked Mar 04 '11 04:03

Kumar sonu


1 Answers

You need to define the UIRotationGestureRecognize on the view that you want to rotate and than add a selector method and implement it like this.

Add this to you viewDidLoad method

UIRotationGestureRecognizer *rotate = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotation:)];

[myUIViewObject addGestureRecognizer:rotate];

[rotate release];

And then implement the method.

- (void) rotation:(UIRotationGestureRecognize *) sender
{
    CGAffineTransform myTransform = CGAffineTransformMakeRotation(sender.rotation);
    sender.view.transform = myTransform;
}

PS. myUIViewObject can be any UIView Object that you want to rotate.

Edit:

you will find a lot of information on this here:

http://www.iphonedevsdk.com/forum/iphone-sdk-development/49847-how-find-angle-two-points.html

like image 115
Robin Avatar answered Oct 01 '22 19:10

Robin