2016-03-02 38 views
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。

我试图谷歌出来,但没有找到任何帮助或解决方案。 任何人都可以请这里的意见,如果有什么不对或需要改变?

谢谢。

+0

的链接给我看看你updateHeadingDisplaysMethod – user3182143

+0

我帮你告诉我你的全编码 – user3182143

+0

我想你的代码,但我得到confusion.It没有调用didUpdateHeading:方法。 – user3182143

回答

相关问题