Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 打开时输入不同的值_Ios_Swift_Unity3d_Location_Compass - Fatal编程技术网

Ios 打开时输入不同的值

Ios 打开时输入不同的值,ios,swift,unity3d,location,compass,Ios,Swift,Unity3d,Location,Compass,我使用Unity3D的GPS跟踪和指南针创建了一个AR应用程序 例如,当我打开应用程序时,trueHeading为260,当我关闭它并以不同的方向再次打开时,然后将设备转到先前的状态,trueHeading为210 我尝试使用swift的IOS本机应用程序,但同样的问题也出现了 这是我的Swift密码 import UIKit import CoreLocation class ViewController: UIViewController ,CLLocationManagerDelegat

我使用Unity3D的GPS跟踪和指南针创建了一个AR应用程序

例如,当我打开应用程序时,trueHeading为260,当我关闭它并以不同的方向再次打开时,然后将设备转到先前的状态,trueHeading为210

我尝试使用swift的IOS本机应用程序,但同样的问题也出现了

这是我的Swift密码

import UIKit
import CoreLocation

class ViewController: UIViewController ,CLLocationManagerDelegate {

    var lm:CLLocationManager!

    override func viewDidLoad() {
        super.viewDidLoad()

        lm = CLLocationManager()
        lm.delegate = self

        lm.startUpdatingHeading()

        Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(printHeading), userInfo: nil, repeats: true)

    }

    @objc func printHeading() {
        print(self.lm.heading?.trueHeading)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
}
同样的问题也发生在
磁性读取上


表示该属性中的值表示相对于地理北极的航向。但是它并没有像预期的那样工作。

我知道你不能得到相同/相似的真/磁航向 从应用程序的跑步到下一次跑步-重复性差

第一步,检查内置的指南针应用程序是否给出与您的应用程序相同的结果。如果两个结果一致,这就是硬件的性能。你能做的几乎是什么都没有

我用两台不同的iPhone测试了我的应用程序。即使我经常把两部手机放在同一个方向上,两部手机也会有不小的差别——10-20度。通过与真(SUNTO)指南针进行比较,我发现出于某种原因,一部手机的性能(真实值和可重复性)较差。我想手动校准iphone的指南针,但没有这样的UI/API,只有iOS决定何时校准

真正的航向只需将偏移量添加到磁航向,其偏移量由位置确定。所以,若磁航向的重复性很差,那个么真航向也是如此