为什么加速计:didAccelerate:在 IOS5 中被弃用? [英] Why is accelerometer:didAccelerate: deprecated in IOS5?

查看:23
本文介绍了为什么加速计:didAccelerate:在 IOS5 中被弃用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IOS5的发布有这个核心功能列为已弃用.有谁知道用什么代替它?我假设苹果不会从 iPhone 5 中移除加速度计.

The release of IOS5 has this core function listed as deprecated. Does anyone know what will replace it? I'm assuming that apple is not going to remove the accelerometer from iPhone 5.

推荐答案

我还没有使用 iOS 5,但是在 4.x 中 UIAccelerometer 和 UIAccelerometerDelegate 已经被 CoreMotion 框架取代了.它更复杂,将陀螺仪信号考虑在内并执行传感器融合,即为您校准诸如偏差计算之类的东西.

I did not yet use iOS 5, but already in 4.x UIAccelerometer and UIAccelerometerDelegate were replaced by the CoreMotion framework. It is more sophisticated, takes gyroscope signals into account and performs a sensor fusion i.e. does calibrating stuff like bias calculation for you.

基本上 CMDeviceMotionHandler 块回调现在是等效的.它被称为每 deviceMotionUpdateInterval 秒,或者您可以使用自己的计时器循环并提取数据.它非常简单易用.查看简单的 iPhone 运动检测,并按照三个链接指向 SDK 文档.

Basically the CMDeviceMotionHandler block callback is now the equivalent. It is called every deviceMotionUpdateInterval seconds or you can go with your own timer loop and pull the data. It is pretty straightforward and easy to use. Look at Simple iPhone motion detect and follow the three links to the SDK docs.

您必须牢记三件事:

  • 使用 Device Motion 需要 iPhone 版本 >= 4 或最新一代的 iPod touch,因为它依赖陀螺仪支持
  • 在使用 Device Motion 时,您不能使用低通滤波来提取重力,因为它是为您完成的
  • 如果您想支持较旧的硬件,则必须使用原始数据.这是通过创建一个 CMAccelerometerHandler 并调用 startAccelerometerUpdatesToQueue:withHandler:.然后你必须像 didAccelerate 那样用低通滤波来提取重力
  • Working with Device Motion requires iPhone version >= 4 or newest iPod touch generation because it relies on gyroscope support
  • When using Device Motion you must not use low pass filtering to extract gravity because it is done for you
  • If you want to support older hardware, you have to work with raw data. This is done by creating a CMAccelerometerHandler and calling startAccelerometerUpdatesToQueue:withHandler:. Then you have to extract gravity with low pass filtering like in didAccelerate

这篇关于为什么加速计:didAccelerate:在 IOS5 中被弃用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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