iphone开发-UIRotationGestureRecognizer(顺时针&计数器顺时针检测)?
有没有办法检测用户所做的旋转是顺时针还是逆时针直接???
我搜索过但找不到答案!
我的代码如下所示:
UIGestureRecognizer *recognizer;
recognizer = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(spin)];
[self.rotating addGestureRecognizer:recognizer];
[recognizer release];
Is there a way to detect if the rotation done by the user is in clockwise or counter clockwise direct???
I searched for that but couldn't find an answer !
My code looks like this:
UIGestureRecognizer *recognizer;
recognizer = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(spin)];
[self.rotating addGestureRecognizer:recognizer];
[recognizer release];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
rotation
属性会告诉您 旋转,以弧度为单位。负值表示顺时针旋转,正值表示逆时针旋转。例子:
the
rotation
property will tell you the rotation in radians. A negative value would indicate the rotation is clockwise, and a positive value indicates counter-clockwise.Example:
Swift 版本 - 假设您已将 UIRotationGestureRecognizer 连接到 IBAction 并传入 UIRotationGestureRecognizer 作为参数
recognizer
。您可以使用以下方法轻松测试方向:Swift version - imagine you've connected your UIRotationGestureRecognizer to an IBAction and are passing in the UIRotationGestureRecognizer as argument
recognizer
. You could very easily test direction with the following: