我有以下快速代码:它旨在找到设备的当前磁航向(即 N、E、S、W)
class ViewController: UIViewController ,CLLocationManagerDelegate {
var lm:CLLocationManager!
override func viewDidLoad() {
super.viewDidLoad()
lm = CLLocationManager()
lm.delegate = self
lm.startUpdatingHeading()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
func locationManager(manager: CLLocationManager!, didUpdateHeading newHeading: CLHeading!) {
println(newHeading.magneticHeading)
}
}
似乎它应该工作,但它没有。有人可以改进它吗?