我嘗試在Swift中使用運動管理器,但我的更新塊內部的日誌從不打印。Motion Manager在Swift中不工作
var motionManager: CMMotionManager = CMMotionManager()
motionManager.accelerometerUpdateInterval = 0.01
println(motionManager.deviceMotionAvailable) // print true
println(motionManager.deviceMotionActive) // print false
motionManager.startDeviceMotionUpdatesToQueue(NSOperationQueue.currentQueue(), withHandler:{
deviceManager, error in
println("Test") // no print
})
println(motionManager.deviceMotionActive) // print false
我的Objective-C實現工作正常。有誰知道爲什麼我的更新塊沒有被調用?