あるCMDeviceMotionの新しいheading propertyは、私はそれを使用するが、それは常に-1.0
だことを見つけようとしているCMDeviceMotionの見出しは-1.0
iOSの11にあります。度はダブルで0.0
から360.0
まで保つことになっています。
マイアプリのターゲットのiOS 11+、と私は、このようなmotion.attitude.roll
のような他の特性だけで罰金を得ることができますiOSの11
let mmgr = CMMotionManager()
mmgr.showsDeviceMovementDisplay = true // for calibrating magnetometer, maybe not needed?
mmgr.deviceMotionUpdateInterval = 0.1
mmgr.startDeviceMotionUpdates(to: .main, withHandler: { (motionData: CMDeviceMotion?, error: Error?) in
if let motion = motionData {
print("heading:", motion.heading) // always -1.0
}
})
を実行している物理デバイス(iPhone)でテストしています。私は行方不明のものがありますか?
要件の良い要約、ありがとう。 – matt
'startDeviceMotionUpdates(using:to:withHandler:)'を呼び出す必要はありませんので、答えで指定する必要はありません。必要なのは、単にモーションマネージャが用語「北」を含む参照フレームを持つ必要があることです。それを保証する他の方法があります。 – matt