【问题标题】:CoreMotion deviceMotionUpdateInterval ignoredCoreMotion deviceMotionUpdateInterval 被忽略
【发布时间】:2015-11-15 00:35:13
【问题描述】:

我正在使用 deviceMotionUpdateInterval,但我在设置它时看不到任何变化。处理程序被最大程度地调用。难道我做错了什么?这是一个错误吗?

var counter = 0

if (motionManager.accelerometerAvailable == true)
{
    self.motionManager.deviceMotionUpdateInterval = 1
    let handler:CMAccelerometerHandler = {(data: CMAccelerometerData?, error: NSError?) -> Void in
        counter++
        print(counter)
    }
    self.motionManager.startAccelerometerUpdatesToQueue(NSOperationQueue.currentQueue()!, withHandler: handler)
}

【问题讨论】:

    标签: swift ios9 core-motion


    【解决方案1】:

    问题是您设置了错误的属性。 deviceMotionUpdateInterval 用于设备运动更新。这不是你所要求的;您已要求更新加速度计。对于加速度计更新,您需要设置accelerometerUpdateInterval

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-09-26
      • 2016-06-05
      • 2014-02-25
      • 2011-05-09
      • 2015-02-08
      • 2011-03-27
      • 2010-11-19
      相关资源
      最近更新 更多