我怎么知道 iPhone 正在移动?

发布于 2024-08-22 10:28:14 字数 245 浏览 5 评论 0原文

有什么办法可以找到iPhone的动静吗?我需要知道 iPhone 是否仍然静止,即它没有移动,然后执行某些操作,否则如果 iPhone 正在移动(垂直或水平方向),则执行一些逻辑。

我需要阅读加速度计 didAccelerate 方法吗?或者还有其他方法,例如读取当前位置(纬度/日志)值。

[我没有 3GS]

请建议哪种是读取 iPhone 运动的最佳且可靠的方法以及如何知道 iPhone 是否静止。

谢谢

Is there any way to find, iPhone movement?. I need to know if iPhone is still i.e its not moving then do some thing or else if iPhone is moving(in vertical or horizontal direction) do some logic.

Do I need to read accelerometer didAccelerate method. Or there is some other way like reading current location (lat/log) values.

[I DON'T have 3GS]

Please suggest which is the best and robust way to read iPhone movement and how to know if iPhone is still.

Thanks

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

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

发布评论

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

评论(1

饮惑 2024-08-29 10:28:14

是的,您需要使用 UIAccelerometer 类。设置委托并对加速度计进行一些计算:didAccelerate 委托消息。

诀窍在于您需要设置一些阈值。如果 x、y 和 z 轴范围内没有 sig 移动,则设备不会移动。

当然,轻微的振动会导致值发生变化,这就是为什么您需要确定什么不移动才适合您的目的。

Yes, you will need to use the UIAccelerometer class. Set the delegate and do some calculations on the accelerometer:didAccelerate delegate message.

The trick is that you will want to set up some threshold values. If there is no sig movement within your range in the x, y, and z axis, the device is not moving.

Of course, slight vibrations will cause value changes, which is why you will need to determine what not moving is for your purposes.

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