The change of system positioning in iOS8

Source: Internet
Author: User

Cllocationmanager This system positioning class before iOS8 to achieve positioning, only need to comply with Cllocationmanagerdelegate this agent can:

-(void) startlocate

{

if ([Cllocationmanager locationservicesenabled]) {

_locmanager = [[Cllocationmanager alloc]init];

[Self.locmanager setdelegate:self];

[Self.locmanager Setdesiredaccuracy:kcllocationaccuracybest];

[Self.locmanager startupdatinglocation];

}

}

-(void) Locationmanager: (Cllocationmanager *) Manager didupdatelocations: (Nsarray *) Locations

{

[_locmanager stopupdatinglocation];

Cllocation *currentlocation = [locations Lastobject];

Cllocationcoordinate2d coor = currentlocation.coordinate;

NSString *latitude = @ (coor.latitude). Description;

NSString *longitude = @ (coor.longitude). Description;

}

IOS8 before the two methods in normal circumstances, has been able to obtain the latitude and longitude of normal. However, under iOS8, you need to add the following code in the Startlocate method after the Cllocationmanager class is instantiated:

if ([[[Uidevice Currentdevice] systemversion] floatvalue] >= 8.0)

{

[Self.locmanager requestalwaysauthorization];

}

However, just adding the above code does not work, and you need to add a key-value pair to the project's Info.plist file:

Key Type Value

Nslocationalwaysusagedescription array/dictionary/boolean/data/date/number/string

Note that the corresponding type above, supported by all seven types, I'll focus on string and Boolean types:

1.Type is a string: value This local developer can explain the specific purpose of the positioning, so that users know clearly what to do after opening the positioning, more transparent, clear;

The "positioning" word in the box is the display of the value set when the type is string.

When value is empty, the box is displayed as follows:

2.Type is Boolean: value is filled with Yes. The box appears as follows:

In the previous iOS8, the bullet box for the location hint appears as follows:

Under IOS8, if you do not do the above two processing, the system Cllocationmanager this class immediately designated proxy, its access to latitude and longitude of the proxy method will not go.

The change of system positioning in iOS8

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.