ios8地图开发的报错
报错如下:Trying to start MapKit location updates without prompting for location authorization. Must call -[CLLocationManager requestWhenInUseAuthorization] or -[CLLocationManager requestAlwaysAuthorization] first.
网上一搜大把类似的帖子
解决办法:在工程的info.plist文件里面添加两项属性。value值为yes
NSLocationWhenInUseUsageDescription
NSLocationAlwaysUsageDescription
代码里面写:
1 _locationManager=[[CLLocationManager alloc]init]; 2 3 if(![CLLocationManager locationServicesEnabled]||[CLLocationManager authorizationStatus]!=kCLAuthorizationStatusAuthorizedWhenInUse){ 4 5 [_locationManager requestWhenInUseAuthorization]; 6 7 } 8 9 [_locationManager setDelegate:self]; 10 11 [_locationManager requestAlwaysAuthorization]; //NSLocationAlwaysUsageDescription 12 13 [_locationManager requestWhenInUseAuthorization]; //NSLocationWhenInUseDescription