I have the following swift code and I tried to test whether the CMMotionManager is working, but every time I use the shake gesture on simulator, the result is not what I expect but a undo tying notification.
let manager = CMMotionManager()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
if manager.deviceMotionAvailable {
manager.deviceMotionUpdateInterval = 0.02
manager.startDeviceMotionUpdatesToQueue(NSOperationQueue.mainQueue()) {
[weak self] (data: CMDeviceMotion?, error: NSError?) in
if data?.userAcceleration.x < -2.5 {
self?.resLabel.text = "Shaked"
}
}
}
}