IOS8 Positioning Problem Solving solution

Source: Internet
Author: User

Originalhttp://blog.csdn.net/nextstudio/article/details/40050095 ThemesiOS81. Modify Info

Added key:nslocationalwaysusagedescription and nslocationwheninuseusagedescription, the two key values will be used to describe the usage and positioning of the application for the duration of use, respectively. , these instructions are displayed in the user settings.

Info new key value pairs are as follows:

Application notes See:

2. Cllocationmanager initialization

Ios8cllocationmanager new instance methods Requestwheninuseauthorization and requestalwaysauthorization need to be called as needed at initialization time.

if ([Cllocationmanager locationservicesenabled]) {  Self.locationmanage = [[Cllocationmanager alloc] init];  Self.locationManage.delegate =Self
Positioning frequency, the number of meters per self.locationManage.distanceFilter = 200;
Set positioning accuracy self.locationManage.desiredAccuracy = kcllocationaccuracybestfornavigation; Kcllocationaccuracybest;
Start Tracking Location
[Self.locationmanage startupdatinglacation]; if (system_version >= 8.0) { //Use period [self.locationmanage Requestwheninuseauthorization]; //Always //or [self.locationmanage requestalwaysauthorization] }}
3. Agent (Cllocationmanagerdelegate)

Failed to locate

-(void) Locationmanager: (Cllocationmanager *) Manager didfailwitherror: (nserror *) error

{

[Mbhuduntil HideAllHUDForView:self.window];

if (![ Shareddata SHAREINSTANCE].ISMB = = NO) {

[Mbhuduntil showhudtowindowwithtext:@ "Map location failed, please confirm that you have allowed the program to open the location service"];

}

}

Track the location agent method, which is executed each time the position changes (as long as it is positioned to the appropriate location)

-(void) Locationmanager: (Cllocationmanager *) Manager didupdatelocations: (Nsarray *) locations{

//If you do not need real-time positioning, use it even if you turn off location services

  [_locationmanager stopupdatinglocation];

}

Add the following proxy methods:

- (void) Locationmanager: (Cllocationmanager *) Manager didchangeauthorizationstatus: (clauthorizationstatus) status{  Switch (status) {    case kclauthorizationstatusnotdetermined:   if ([self.locationmanage respondstoselector:@ Selector (requestalwaysauthorization)])    {    [self.locationmanage Requestwheninuseauthorization];   }   break;  default:   Break }              /span>             

IOS8 solution for locating problems

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.