IOS8 post-update location problem cllcationmanage

Source: Internet
Author: User

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

    • Nslocationalwaysusagedescription

    • Nslocationwheninuseusagedescription

(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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.