iOS Dev-app when running on iOS 8 simulator, locate the card dead bug resolved

Source: Internet
Author: User

Compiling on IOS 8 will show the following log:

Trying to start Mapkit location updates without prompting for location authorization. Must call-[cllocationmanager requestwheninuseauthorization] or-[cllocationmanager requestalwaysauthorization] First .

The search has been resolved as follows:

1, modify Info.plist:

New key value is Nslocationwheninuseusagedescription or nslocationalwaysusagedescription (here, I will add two), value can be empty, you can also set a Yes, However, my problem still can not be solved, eventually found the problem is that info.plist also need to include supported interface orientations this array field. Then the operation is resolved.

2. Modify the code:

Add a sentence before calling the method startupdatinglocation

if ([Locationmanager respondstoselector: @selector (requestwheninuseauthorization)]) {    [Locationmanager Requestwheninuseauthorization];}
3. How to modify the original blog:

Locationmanager = [[Cllocationmanager alloc] init];        Locationmanager.delegate = self;        Locationmanager.desiredaccuracy=kcllocationaccuracybest;        if ([Locationmanager respondstoselector: @selector (requestwheninuseauthorization)]) {            [Locationmanager Requestwheninuseauthorization];        }        [Locationmanager startupdatinglocation];
-(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 *mes        Sage = @ "Your phone is not currently open for location services, so if you want to start the location service, please go to Settings------------Privacy Uialertview *alertview = [[Uialertview alloc] initwithtitle:@ "Unable to locate" Message:message delegate:nil cancelbuttontitle:@ "        Make sure "Otherbuttontitles:nil";    [Alertview show];    }else {[Locationmanager startupdatinglocation]; }}
The above line is iOS 8 and the second line is below iOS 7 because kclauthorizationstatusauthorized is not available in iOS 8 at all.
Clauthorizationstatus status = [Cllocationmanager authorizationstatus];        if (status = = Kclauthorizationstatusauthorizedwheninuse | | status = = kclauthorizationstatusauthorized) {    //start location} else {    //Display warning}

iOS Dev-app when running on iOS 8 simulator, locate the card dead bug resolved

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.