Reputation: 8720
I'm using a WiFi iPad 1st gen with iOS 5.1.1
I have set up Core Location similar to this blog post: http://blog.objectgraph.com/index.php/2012/01/10/how-to-create-a-compass-in-iphone/
In:
- (void)locationManager:(CLLocationManager*)manager
didUpdateHeading:(CLHeading*)heading
I log the true heading value:
NSLog(@"heading: %f", manager.heading.trueHeading);
The result is always "true heading: -1.000000" no matter which direction I point the iPad.
I've rotated the device on all 3 axis and enabled location services in settings.
Any ideas on why this doesn't work? Does heading reporting not work on an iPad 1st gen?
Upvotes: 2
Views: 1596
Reputation: 7022
Here is what helped in my case :
It seems that this way, the trueheading-values no longer turn out to be -1 !
(see picture below) !
Upvotes: 3
Reputation: 70265
To get valid heading data you must also configure the CLLocationManager to update location as well. From the Apple documentation:
Note: If you want heading objects to contain valid data for the trueHeading property, your location manager object should also be configured to deliver location updates. You can start the delivery of these updates by calling the location manager object’s startUpdatingLocation method.
Thus call startUpdatingLocation
Note that 'heading' refers to the direction that a defined device axis is pointed. The 'orientation', which you can read with [UIDevice currentDevice].orientation tells you the tilt of the device.
Upvotes: 2
Reputation: 77301
The -1 means the compass heading is invalid. You probably need to perform compass calibration.
Upvotes: 1