触摸时旋转视图

发布于 2024-10-20 03:23:23 字数 150 浏览 1 评论 0原文

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

在此处输入图像描述

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

春夜浅 2024-10-27 03:23:23

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

将其添加到您的 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;
}

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

编辑:

您将在这里找到很多相关信息:

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文