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