In the Xcode6, the location method of the Apple map has been modified, it was not used before
Error description: Trying to start mapkit location updates without prompting for location authorization. Must call-[cllocationmanager requestwheninuseauthorization] or-[cllocationmanager requestalwaysauthorization] First .
Workaround:
Add nslocationalwaysusagedescription or XXX.info.plis inside the supporting files. Nslocationwheninusedescription Two string field, value can be empty, can also set yes, but I have to solve the problem, and eventually found the problem is that info.plist also need to include supported interface orientations this array field. Then the operation is resolved.
Code handling:
Locationmanager = [[Cllocationmanager alloc] init]; Locationmanager.delegate = self; Locationmanager.desiredaccuracy=kcllocationaccuracybest; if ([Locationmanager respondstoselector: @selector (requestwheninuseauthorization)]) { [Locationmanager Requestwheninuseauthorization]; } [Locationmanager startupdatinglocation];
Another place:
-(void) Locationmanager: (Cllocationmanager *) Manager didchangeauthorizationstatus: (clauthorizationstatus) Status {if ([Locationmanager respondstoselector: @selector (requestwheninuseauthorization)] && Status! = kclauthorizationstatusnotdetermined && status = kclauthorizationstatusauthorizedwheninuse) | | (! [Locationmanager respondstoselector: @selector (requestwheninuseauthorization)] && Status! = kclauthorizationstatusnotdetermined && Status! = kclauthorizationstatusauthorized) {NSString *message = @ "your phone is not currently open for location services, if you want to turn on location services, go to set up the location service function";Uialertview *alertview = [[Uialertview alloc] initwithtitle:@ "Unable to locate" message:message delegate:nil cancelbuttontitle:@" OK "otherbuttontitles:nil]; [Alertview show]; }else {[Locationmanager startupdatinglocation]; }}
Above that line is iOS 8 above, the second line is below iOS 7, kclauthorizationstatusauthorized in iOS 8 is completely unable to use.
Other places:
Clauthorizationstatus status = [Cllocationmanager authorizationstatus]; if (status = = Kclauthorizationstatusauthorizedwheninuse | | status = = kclauthorizationstatusauthorized) { //start positioning} else { //Prompt Warning}
The code modification fragment originates from this: http://blog.dreambreakerx.com/tag/ios/
Shows user location cannot use map positioning on iOS8