IOS8 positioning Supplement

Source: Internet
Author: User

IOS 8 Location Supplement

IOS 8 targeting needs to be modified in 2 places

Add Nslocationalwaysusagedescription: Description information in the 1.info.plist file

Starting with iOS 8, user location is always used in two situations: Nslocationalwaysusagedescription when using the app: Nslocationwheninusedescription

2. Calling in Cllocationmanager

-(void) requestalwaysauthorization

-(void) requestwheninuseauthorization

#import "ViewController.h"#import<CoreLocation/CoreLocation.h>@interfaceViewcontroller () <CLLocationManagerDelegate>@property (nonatomic,strong) Cllocationmanager*Mgr;@end@implementationViewcontroller- (void) viewdidload {[Super viewdidload];        [Self.mgr startupdatinglocation]; //if it is iOS8, you need to request authorization method (to judge, otherwise the iOS7 will crash, need to first configure in Info.plist)//1. Determine if a request for Requestalwaysauthorization authorization is required by judging the system's judgment//if ([Uidevice currentdevice].systemversion.floatvalue >= 8.0) {//[Self.mgr requestalwaysauthorization];//    }    //2. Determine if you need to request requestalwaysauthorization authorization by judging whether this method is available    if([Self.mgr respondstoselector: @selector (requestalwaysauthorization)]) {[Self.mgr requestalwaysauthorization]; }}- (void) Locationmanager: (Cllocationmanager *) Manager didupdatelocations: (Nsarray *) locations{NSLog (@"get to the user's location");}-(Cllocationmanager *) mgr{if(_mgr = =Nil) {_mgr=[[Cllocationmanager alloc] init]; _mgr.Delegate=Self ; }        return_mgr;}@end

IOS8 positioning Supplement

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.