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

查看:100
本文介绍了为什么加速度计: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天全站免登陆