在触摸时旋转视图 [英] rotating a view on touch

查看:93
本文介绍了在触摸时旋转视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

推荐答案

您需要定义 UIRotationGestureRecognize 在你想要旋转的视图上,然后添加一个选择器方法并像这样实现它。

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.

将此添加到你 viewDidLoad 方法

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

[myUIViewObject addGestureRecognizer:rotate];

[rotate release];

然后实施该方法。

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

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

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

编辑:

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

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

这篇关于在触摸时旋转视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆