Question

My app might be without attention for a long time with GPS/Heading active. To manage if the calibrate compass popup comes I've done this.

-(BOOL) locationManagerShouldDisplayHeadingCalibration:(CLLocationManager *)manager {
//    NSTimer *dismissHeadingSoon;
//    dismissHeadingSoon = [NSTimer scheduledTimerWithTimeInterval:200
//         target:self selector:@selector(removeHeadingCalibration:) userInfo:nil repeats:NO];
      return YES;
}

-(void) removeHeadingCalibration:(NSTimer *)timer {
    [locationManager dismissHeadingCalibrationDisplay];
}   

I want a timer to dismiss the popup after a while (comment out above). My problem is: the calibration screen now just shows up for half a second and disappear directly? So my code now only says YES without any timer starting. If I remove the delegate it works as it should.

Documentation says "Return Value YES if you want to allow the heading calibration alert to be displayed; NO if you do not."

What have I done wrong? (ios7 and xcode 5.1)

Was it helpful?

Solution

after discussions with Apple DTS engineer it turns out that you can't use the heading features in mapView (MKUserTrackingModeFollow) if you also have a location manager connected. You need to set the userTrackingMode to MKUserTrackingModeNone and use MKMapCamera to display your map with heading coming from location manager. When I implement locationManagerShouldDisplayHeadingCalibration, my delegate ends up colliding with the map view's and they end up canceling each other out. That's why leaving it off causes the calibration screen to appear. Since my app will be used for hours without attention the cancellation of the calibration screen is important and this way I can have it both.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top