IOS 8 beta - Location Manager Does not register user location

Since the release of the new beta version of iOS 8, I have not been able to successfully get the user's location. Prior to upgrading to iOS 8, I had no problems, but now it always returns 0.000000 as the current latitude and longitude. Is this just a bug in the new version? My code is below:

//from the .h file @interface MasterViewController : PFQueryTableViewController<CLLocationManagerDelegate,UITextFieldDelegate, UISearchBarDelegate, UISearchDisplayDelegate> { } @property (nonatomic, strong) CLLocationManager *locationManager; //from the .m file @synthesize locationManager = _locationManager; - (void)viewDidLoad { [super viewDidLoad]; [self.locationManager startUpdatingLocation]; } - (CLLocationManager *)locationManager { if (_locationManager != nil) { return _locationManager; } _locationManager = [[CLLocationManager alloc] init]; _locationManager.delegate = self; _locationManager.desiredAccuracy = kCLLocationAccuracyBest; return _locationManager; } - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { } - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error { } 

UPDATE This question has been answered ( Location services not working in iOS 8 ). For those who are still struggling with this in order to maintain backward compatibility with iOS 7, I used the following code:

 if ([self.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) { } 
+7
ios ios8 core-location mapkit
source share
1 answer

As indicated in your update / comment, iOS8 requires the use of requestAlwaysAuthorization or requestWhenInUseAuthorization , as well as the new NSLocationAlwaysUsageDescription or NSLocationWhenInUseUsageDescription in Info.plist

But there is something else in your code:

 - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation 

It is deprecated in iOS6, and now you should use this new delegate method:

 - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations 

Then you can get the last place with something like this:

 CLLocation *newLocation = [locations lastObject]; 
+2
source share

All Articles