The previous method cllocationmanagerdelegate not call didupdatelocations after the IOS8 update
IOS8 modified the content in the location settings, added a set of States (available in use/usually available), so after the registration of the previous cllcationmanage,
The delegate interface did not respond, and the study was finally able to use the morning
Say something about my experience.
(1) Add Corelocation.framework
(2) add two fields that are not in default in Info.plist
(3) Import header file
#import <CoreLocation/CoreLocation.h>
#import <CoreLocation/CLLocationManagerDelegate.h>
@interface Personviewcontroller:uiviewcontroller<cllocationmanagerdelegate>{ cllocationmanager* Locationmanager;} @property (Strong, nonatomic) Cllocationmanager* Locationmanager; @end
(4) Instantiate and complete the proxy method
-(void) startlocation{[Self.locationmanager requestalwaysauthorization]; if([Cllocationmanager locationservicesenabled]&&[cllocationmanager authorizationstatus]! =kclauthorizationstatusdenied) {Self.locationmanager=[[Cllocationmanager alloc] init]; [Self.locationmanager Setdesiredaccuracy:kcllocationaccuracybest]; Self.locationmanager.Delegate=Self ; if(__iphone_8_0) {NSLog (@" Here"); Self.locationManager.distanceFilter=Kcldistancefilternone; [Self.locationmanager Setdesiredaccuracy:kcllocationaccuracynearesttenmeters]; } NSLog (@"That ' s here"); [Self.locationmanager startupdatinglocation]; }}- (void) Locationmanager: (Cllocationmanager *) Manager didchangeauthorizationstatus: (clauthorizationstatus) Status {Switch(status) { Casekclauthorizationstatusnotdetermined:if([Locationmanager respondstoselector: @selector (requestalwaysauthorization)]) {[Locationmanager requestwhe Ninuseauthorization]; } Break; default: Break; }}//positioning agent latitude and longitude callback-(void) Locationmanager: (Cllocationmanager *) Manager didupdatelocations: (Nsarray *) locations{[Locationmanager stopupdatinglocation]; NSLog (@"Location OK"); Cllocation*currentlocation =[Locations Firstobject]; NSLog (@"%@", [NSString stringWithFormat:@"Longitude:%3.5f\n Latitude:%3.5f", Currentlocation.coordinate.latitude,currentlocation.coordinate.longitude]); Clgeocoder* GeoCoder =[[Clgeocoder alloc] init]; [GeoCoder reversegeocodelocation:currentlocation Completionhandler:^ (Nsarray *placemarks, Nserror *error) { for(Clplacemark * Placemarkinchplacemarks) {Nsdictionary*test =[Placemark addressdictionary]; //Country (country) state (city) sublocality (district)NSLog (@"%@", [Test Objectforkey:@" State"]); _locationcity.text= [Test Objectforkey:@"sublocality"]; } }];}- (void) Locationmanager: (Cllocationmanager *) Manager didfailwitherror: (Nserror*) Error {if(Error.code = =kclerrordenied) {NSLog (@"location%ld",(Long) Error.code); }}
(5) Set start positioning end positioning
-(void) viewwillappear: (BOOL) animated{ [Super viewwillappear:animated]; // Start Positioning }-(void) viewwilldisappear: (BOOL) animated{ [Super viewwilldisappear:animated]; // stop positioning }
If you can not locate the Welcome message exchange!
IOS8 the problem after updating Cllcationmanage