How to calibrate iPhone 3Gs Compass within an App?
I'm having a problem every now and then though with the app giving me -1 constantly as the heading until I exit, open Apple's compass App, then start my app again. It immediately starts working when I do that.
This problem doesn't happen all the time, but every now and then while I'm testing or after a day, it'll happen again. And it seems to be a calibration issue, and Apple's compass App is obviously able to do it instantly.
Another thing I noticed when this happens is if you open the Apple Compass App when I'm getting -1 values, for a split second Apple's compass will show 0 degrees, then the right one.
It must be doing some calibration when you start their app. Does anyone know how to perform that same calibration in an app? I looked through the CoreLocationManager documentation and couldn't find anything that said anything about calibrating, except for this:
+- (void)dismissHeadingCalibrationDisplay+
+Core Location uses the heading calibration panel to calibrate the available heading hardware as needed. The display of this view is automatic, assuming your delegate supports displaying the view at all. If the view is displayed, you can use this method to dismiss it after an appropriate amount of time to ensure that your application’s user interface is not unduly disrupted.+
So that's to dismiss the calibration display, but how do display the heading calibration panel or have it called?
And the way I implement the heading is as follows:
locationController = [[MyCLController alloc] init];
locationController.delegate = self;
[locationController.locationManager startUpdatingHeading];
locationController is a MyCLController which is the class in Apple's LocateMe Sample App.
And I implement these two functions:
- (void)locationErrorNSError *)error
- (void)headingUpdateCLHeading *)heading
which get the events from the CLLocationManager delegate
Any ideas how to do this?
Macbook Pro 13", Mac OS X (10.5.8), Leopard