This is due to the location permission setting issue caused by the Xcode upgrade.
Upgrade Xcode6 After opening the previous XCODE5 project, the program cannot be located. Project upgrade to Xcode6 compile requires iOS8 to write their own authorization, or do not have permission to locate.
Workaround:
First, the corresponding default field is added to the Info.plist, the value is set to Yes (foreground position write top field, front and back position write bottom field)
Nslocationwheninuseusagedescription//Allow GPS description to be obtained at the front desk
Nslocationalwaysusagedescription//Allow the description of GPs to be obtained in front and backstage
Rear drawings
First on the code:
?
| 123456789101112131415161718192021222324252627282930313233343536 |
#import "ViewController.h"#import <CoreLocation/CoreLocation.h>@interface ViewController ()<CLLocationManagerDelegate>@property (nonatomic, strong) CLLocationManager *locationManager;@end@implementation ViewController// 1. 懒加载初始化:- (CLLocationManager *)locationManager{ if(!_locationManager){ self.locationManager = [[CLLocationManager alloc] init]; self.locationManager.delegate = self; } return _locationManager;}- (void)viewDidLoad { [super viewDidLoad];// 2. 调用请求: if ([[[UIDevice currentDevice] systemVersion] doubleValue] > 8.0) { //设置定位权限 仅ios8有意义 [self.locationManager requestWhenInUseAuthorization];// 前台定位 // [locationManager requestAlwaysAuthorization];// 前后台同时定位 } [self.locationManager startUpdatingLocation];}// 3.代理方法- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{ NSLog(@"%ld",locations.count);}@end |
Picture: Figure. png
Cllocationmanagerdelegate do not call Didupdatelocations (map)