如何在桌子正面朝上的情况下检测iPhone是否在旋转? [英] How can I detect if an iPhone is rotating while being face up in a table?

查看:139
本文介绍了如何在桌子正面朝上的情况下检测iPhone是否在旋转?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以检测放置在桌子上方的iphone是否正在旋转?我确实意识到加速度计没有报告这种运动,也没有报告给-(BOOL)应该AutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation方法.

Is there a way to detect if an iphone lying down in a table face up is rotating?. I do realize that this kind of movement is not reported by the accelerometer and neither is it reported to the - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation method.

有没有一种方法可以检测以这种方式旋转的手机的角度变化?谢谢.

Is there a way to detect angle variations for the phone rotating this way?. Thank you.

推荐答案

重力向量在平面上旋转时将保持恒定,因此您在加速度计上看不到任何东西.您可以遵循指南针方向更改来检测此旋转,但只能在iPhone 3GS上进行.请参见

The gravity vector will be constant as it rotates on a flat table so you won't see anything on the accelerometers. You could follow compass heading changes to detect this rotation but only on an iPhone 3G S. See the CLLocationManager for details, look at the heading methods.

编辑-使用iPhone 4,您可以使用陀螺仪检测旋转. iOS 4中有一个名为 CMMotionManager 以获得

EDIT - With an iPhone 4 you can detect the rotation using the gyros. There is a new class in iOS 4 called CMMotionManager for getting rotation rate from the gyros.

这篇关于如何在桌子正面朝上的情况下检测iPhone是否在旋转?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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