2015-07-01 2 views
4

Я пытаюсь интегрировать модуль компаса в свое приложение. Я использовал CoreLocation Framework, и я добавил CLLocationManagerDelegate в свой класс. Я инициализирую свой класс этим кодом.Создание приложения Compass iOS в Swift

locationManager.delegate = self 
locationManager.desiredAccuracy = kCLLocationAccuracyBest 
locationManager.requestWhenInUseAuthorization() 
locationManager.startUpdatingLocation() 

Затем я вызываю функцию ниже, но я не получаю никакого вывода.

func locationManager(manager: CLLocationManager, didUpdateHeading newHeading: CLHeading) { 
    let h = newHeading.magneticHeading 
    let k = newHeading.trueHeading 
    print(h) 
    print(k) 
    label.text = "\(h)" 
} 

Я добавил NSLocationWhenInUseUsageDescription моим Info.plist

Заранее спасибо.

ответ

5

вы пропустите ..

locationManager.startUpdatingHeading 

//Starts the generation of updates that report the user’s current heading. 
- startUpdatingHeading 

//Starts the generation of updates that report the user’s current location. 
- startUpdatingLocation 
+0

Yess! огромное спасибо –

Смежные вопросы