作者:林友骏091 | 来源:互联网 | 2023-09-09 13:42
CananyoneprovidemewithashortsnippetthatwillreturnmethemagneticheadingoftheiPhone?I
Can anyone provide me with a short snippet that will return me the magnetic heading of the iPhone? I do not want Objective-C please. I need it in Swift.
任何人都可以提供一个简短的片段,让我回到iPhone的磁性标题?我不想要Objective-C。我在Swift中需要它。
I have written these lines so far but it does not return me any value:
到目前为止我已写过这些行,但它并没有给我任何价值:
let locManager = CLLocationManager()
locManager.desiredAccuracy = kCLLocationAccuracyBest
locManager.requestWhenInUseAuthorization()
locManager.startUpdatingLocation()
locManager.startUpdatingHeading()
locManager.headingOrientation = .portrait
locManager.headingFilter = kCLHeadingFilterNone
print(locManager.heading?.trueHeading.binade as Any)
Thanks!
谢谢!
1 个解决方案