CLLocationManagerDelegate does not call didUpdateLocations (MAP), cllocationmanager
This is because of the location permission setting problem caused by xcode upgrade.
After upgrading xcode6, open the previous xcode5 project and the program cannot be located. When the project is upgraded to xcode6, you need to write and authorize iOS8 by yourself. Otherwise, you do not have permission to locate the project.
Solution:
First, add the corresponding default field to info. plist, and set the value to YES (write the above field in the foreground positioning and write the following field in the foreground and background positioning)
NSLocationWhenInUseUsageDescription // you can obtain the GPS description on the foreground.
NSLocationAlwaysUsageDescription // allows you to obtain the GPS description in the front and back ends.
Rear chart
First run the Code:
?
123456789101112131415161718192021222324252627282930313233343536 |
#import "ViewController.h" #import <CoreLocation/CoreLocation.h> @interface ViewController ()<CLLocationManagerDelegate> @property ( nonatomic , strong) CLLocationManager *locationManager; @end @implementation ViewController // 1. Lazy loading initialization: - (CLLocationManager *)locationManager{ if (!_locationManager){ self .locationManager = [[CLLocationManager alloc] init]; self .locationManager.delegate = self ; } return _locationManager; } - ( void )viewDidLoad { [ super viewDidLoad]; // 2. Call the request: if ([[[UIDevice currentDevice] systemVersion] doubleValue] > 8.0) { // The positioning permission is valid only for ios8. [ self .locationManager requestWhenInUseAuthorization]; // Foreground location // [LocationManager requestAlwaysAuthorization]; // locates at the front and back ends simultaneously } [ self .locationManager startUpdatingLocation]; } // 3. Proxy Method - ( void )locationManager:(CLLocationManager *)manager didUpdateLocations:( NSArray *)locations{ NSLog (@ "%ld" ,locations.count); } @end |
Image: fig. PNG