TigerCoding
TigerCoding

Reputation: 8720

Why does my heading not change using Core Location?

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

Answers (3)

iKK
iKK

Reputation: 7022

Here is what helped in my case :

  1. Select Location Services (under privacy settings)
  2. Select System Services at the bottom of the list of apps (in the Location Services)
  3. Turn your Compass Calibration ON

It seems that this way, the trueheading-values no longer turn out to be -1 !

(see picture below) !

enter image description here

Upvotes: 3

GoZoner
GoZoner

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

progrmr
progrmr

Reputation: 77301

The -1 means the compass heading is invalid. You probably need to perform compass calibration.

Upvotes: 1

Related Questions