1. add key nslocationwheninuseusagedescription in Info.plist, nslocationalwaysusagedescription.
2.CLLocationManager Remember to define a member variable, or attribute, otherwise cause the system prompt to open the position prompt box
3. Directly on the code
#pragma mark-cllocationmanagerdelegate
-(void) startlocation{
self. Locationmanager = [[cllocationmanager alloc] init];
self. Locationmanager . Delegate = Self ;
}
-(void) Locationmanager: ( Cllocationmanager *) Manager didchangeauthorizationstatus: (clauthorizationstatus) status{
Switch (status) {
case kclauthorizationstatusnotdetermined:
if([self. Locationmanager respondstoselector:@selector(requestalwaysauthorization)]) {
[self. Locationmanager requestwheninuseauthorization];
}
break;
case kclauthorizationstatusdenied:
[uialertview bk_alertviewwithtitle:@ " please set the - Privacy -Location- enabled service! " ];
break;
case kclauthorizationstatusrestricted:
[uialertview bk_alertviewwithtitle:@ " positioning Service is not available! "];
default:
break;
}
}
4. Use Mkmapview positioning directly after opening.
iOS8 positioning problems (recommended for Cllocationmanager and Mkmapview use)