我试图在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实现运行正常。有人知道为什么我的更新块没有被调用吗?