ios – 找到运动的方向?

前端之家收集整理的这篇文章主要介绍了ios – 找到运动的方向?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个图像(平面图),我固定了我当前的位置.使用CMPedometer我能够找到移动的步数但无法找到我移动的方向.

if(CMPedometer.isStepCountingAvailable()){

    self.pedoMeter.startUpdates(from: midnightOfToday) { (data: CMPedometerData?,error) -> Void in

        DispatchQueue.main.async(execute: { () -> Void in
            if(error == nil) {
                self.stepsLabel.text = "Moved \(data!.numberOfSteps) steps"
            }
        })
    }
}

有没有办法找到我正在移动的方向(与我的观点相关或与E,W,S,N相关)?

解决方法

CMMotionManager为您提供与磁力计一起使用的API.

它应该用于确定航向(北).

猜你在找的iOS相关文章