I make a location app. But Core Location does not work.
I tested other iPhone application on my iPhone.
Like google earth, a navigation software.
The other applications do not work also.
Why doesn't update location?
Why 'locationManager:didUpdateToLocation:fromLocation:' message called 2 times only?
Maybe... My iPhone broken down? or iOS 6 CoreLocation frameworks have some bug?
Location service - On on iPhone settings
Info.plist
- armv7
- accelerometer
- location-services
- gps
- microphone
- magnetometer
Code Example:
- (CLLocationManager *)setupLocationManager
{
if ([CLLocationManager locationServicesEnabled] && [CLLocationManager headingAvailable]) {
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.headingFilter = kCLHeadingFilterNone;
[locationManager startUpdatingLocation];
[locationManager startUpdatingHeading];
return locationManager;
}
return nil;
}
- (CLLocationManager *)locationManager
{
switch([CLLocationManager authorizationStatus])
{
case kCLAuthorizationStatusAuthorized:
_deltaTimeLocationReceived = 0.0;
if (_locationManager == nil)
_locationManager = [self setupLocationManager];
return _locationManager;
case kCLAuthorizationStatusDenied:
case kCLAuthorizationStatusRestricted:
if (_locationManager)
_locationManager = nil;
return _locationManager;
case kCLAuthorizationStatusNotDetermined:
_deltaTimeLocationReceived = 0.0;
if (_locationManager == nil)
_locationManager = [self setupLocationManager];
return nil;
}
return nil;
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
NSLog(@"%@ %@", NSStringFromSelector(_cmd), newLocation.description);
if (self.locationManager) _locationSignal++;
}
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
NSLog(@"%@ %@", NSStringFromSelector(_cmd), error.description);
}