【问题标题】:How to make this CoreMotion code work on retina iPod touch devices?如何使这个 CoreMotion 代码在视网膜 iPod touch 设备上工作?
【发布时间】:2012-08-09 15:13:32
【问题描述】:

我开发了一个使用 CoreMotion 获取倾斜信息的小应用程序。

但它不适用于 iPod touch。我在第一台装有 iOS 5.1 的视网膜显示器 iPod touch 上进行了测试。 gyroAvailable 属性返回 YES,所以我假设这个 iPod 确实有一个陀螺仪。

此代码在 iPhone 4 上运行良好:

CMMotionManager *mm = [[CMMotionManager alloc] init];
self.motionManager = mm;
[motionManager setDeviceMotionUpdateInterval:0.05];

CMDeviceMotionHandler motionHandler = ^(CMDeviceMotion *motion, NSError *error) {
    [self handleMotion:motion error:error];
};

[motionManager startDeviceMotionUpdatesUsingReferenceFrame:CMAttitudeReferenceFrameXArbitraryCorrectedZVertical toQueue:[NSOperationQueue currentQueue] withHandler:motionHandler];

startDeviceMotionUpdatesUsingReferenceFrame 似乎是罪魁祸首,但我无法从文档中确定此方法不适用于没有陀螺仪的设备。

我所需要的只是用户在纵向模式下向左或向右倾斜设备的精确输出。

我有什么选择?

【问题讨论】:

    标签: iphone ios accelerometer ipod-touch core-motion


    【解决方案1】:

    如果您想使用 iPod,请使用“CMAttitudeReferenceFrameXArbitraryZVertical”。 因为 iPad 没有磁力计。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-24
      • 2011-10-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-26
      相关资源
      最近更新 更多