0
iPhoneを横に振ってナビゲーションを作成しようとしています。しかし、何も働いていないようです。加速度計は登録されていませんか? - Swift
override func viewDidLoad() {
super.viewDidLoad()
let manager = CMMotionManager()
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!.firstView.hidden = true
}
}
}
私はCore MotionとCore Locationをインポートしており、何が間違っているのか分かりません。