如何更正swift中的startGyroscopeUpdatesToQueue错误

时间:2015-09-18 22:33:02

标签: swift ios8 gyroscope

我刚刚将xcode更新为7.0,现有的陀螺仪代码现在给我一个错误。我已经玩了好几个小时了,我无法弄清楚这一点。我该如何纠正?

    override func viewDidLoad() {

    if motionManager.gyroAvailable {

        motionManager.startGyroUpdates()
        motionManager.deviceMotionUpdateInterval = 0.2
        motionManager.startDeviceMotionUpdates()

        motionManager.gyroUpdateInterval = 0.2
        motionManager.startGyroUpdatesToQueue(NSOperationQueue.currentQueue()!) {
            [weak self] (gyroData: CMGyroData!, error: NSError!) in

            self!.outputRotationData(gyroData.rotationRate)
            if error != nil {
                print("\(error)")
            }

        }
    } else {
        print("gyro not avail")
    }

    super.viewDidLoad()
}

错误1: 无法将类型'(CMRotationRate,error:NSError.Type)'的值转换为预期的参数类型'CMGyroHandler'(又名'(可选,可选) - >()')

0 个答案:

没有答案