在触摸时旋转视图

Kum*_*onu 7 iphone objective-c rotation uiimageview uigesturerecognizer

我必须在手指触摸上循环旋转视图...我的意思是像拨打旧手机号码......触摸应该只在角落.....任何人都可以帮助我...我试过它很多......但没有成功

在此输入图像描述

Rob*_*bin 11

您需要UIRotationGestureRecognize在视图上定义要旋转的内容,然后添加选择器方法并像这样实现它.

将此添加到您的viewDidLoad方法

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

[myUIViewObject addGestureRecognizer:rotate];

[rotate release];
Run Code Online (Sandbox Code Playgroud)

然后实现该方法.

- (void) rotation:(UIRotationGestureRecognize *) sender
{
    CGAffineTransform myTransform = CGAffineTransformMakeRotation(sender.rotation);
    sender.view.transform = myTransform;
}
Run Code Online (Sandbox Code Playgroud)

PS.myUIViewObject可以是UIView您要旋转的任何对象.

编辑:

你会在这里找到很多相关信息:

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