1
我正嘗試接收iPhone的標題(指向哪個手機的方向)。CLLocationManager-標題不適用於iPhone 6s和6s Plus
我想下面的代碼,
- (void)startHeadingEvents {
if (!self.locManager) {
CLLocationManager* theManager = [[[CLLocationManager alloc] init] autorelease];
// Retain the object in a property.
self.locManager = theManager;
locManager.delegate = self;
}
// Start location services to get the true heading.
locManager.distanceFilter = 1000;
locManager.desiredAccuracy = kCLLocationAccuracyKilometer;
[locManager startUpdatingLocation];
// Start heading updates.
if ([CLLocationManager headingAvailable]) {
locManager.headingFilter = 5;
[locManager startUpdatingHeading];
}
}
- (void)locationManager:(CLLocationManager *)manager didUpdateHeading: (CLHeading *)newHeading {
if (newHeading.headingAccuracy < 0)
return;
// Use the true heading if it is valid.
CLLocationDirection theHeading = ((newHeading.trueHeading > 0) ?
newHeading.trueHeading : newHeading.magneticHeading);
self.currentHeading = theHeading;
[self updateHeadingDisplays];
}
它類似於蘋果的iOS開發者庫和編程指南。 該代碼始終返回0到10或355到359之間的標題度。我沒有得到兩者之間的值。
更多的,我只在iPhone 6S和iPhone 6S plus上遇到這個問題。否則,這完全適用於iPhone 4S,5,5S,6,6 Plus。我所有的手機都使用最新的iOS。
我試圖谷歌出來,但沒有找到任何幫助或解決方案。 任何人都可以請這裏的意見,如果有什麼不對或需要改變?
謝謝。
的鏈接給我看看你updateHeadingDisplaysMethod – user3182143
我幫你告訴我你的全編碼 – user3182143
我想你的代碼,但我得到confusion.It沒有調用didUpdateHeading:方法。 – user3182143