Recently, using the Cllocationmanager location service in ios8.0, I found that the old can't be located, and the items in the Settings menu are also in an unknown state. Remember that there was a popup box prompting the user whether to allow positioning, This has not been the case. The original ios8.0 under the location service needs to apply for authorization. The specific code is as follows:
1 if([Cllocationmanager locationservicesenabled]) {2 3Self.locationmanager =[[Cllocationmanager alloc] init];4 5_locationmanager.Delegate=Self ;6 7_locationmanager.desiredaccuracy = Kcllocationaccuracybest;//control the positioning accuracy, the higher the power consumption of the greater. 8 9_locationmanager.distancefilter = -;//controls the frequency of location service updates. Unit is "M"Ten One [_locationmanager startupdatinglocation]; A - //under iOS 8.0 to authorize - the if([[[[Uidevice Currentdevice] systemversion] Floatvalue] >=8.0) - -[_locationmanager requestwheninuseauthorization];//call this sentence, will pop up the Allow box. - +}
Attention:
In the Info.plist file also add nslocationwheninuseusagedescription this key,value can be empty,
1 #pragmaMark-cllocationmanagerdelegate2 3- (void) Locationmanager: (Cllocationmanager *) Manager didupdatelocations: (Nsarray *) Locations {4 5 6 7Cllocation * Currlocation =[Locations Lastobject];8 9 Ten OneNSLog (@"%@", [NSString stringWithFormat:@"%.3f", CurrLocation.coordinate.latitude]); A -NSLog (@"%@", [NSString stringWithFormat:@"%.3f", CurrLocation.coordinate.longitude]); - the}
System authorization is required to use Cllocationmanager location service under IOS8