If you are Xcode6 and iOS 8, you need to call the Cllocationmanager Requestalwaysauthorization method, as follows:
1. @interface:
Cllocationmanager *locationmanager;
2. Initialize:
Locationmanager = [[Cllocationmanager alloc] init];
3. Call Request:
[Locationmanager requestalwaysauthorization];
[Locationmanager startupdatinglocation];
4. Add in Info.plist:
Nslocationwheninusedescription, allowing GPS descriptions to be obtained at the front desk
Nslocationalwaysusagedescription, allows the description of GPs to be acquired in the background
PS: It is perfect to judge the iOS version before calling the request.
Perfect for a moment:
Whether IOS 8 is judged
if ([Self.locationmanager respondstoselector: @selector (requestalwaysauthorization)]) {
[Self.locationmanager requestalwaysauthorization]; Permanent License
[Self.locationmanager requestwheninuseauthorization]; Licensing in use
}
[Self.locationmanager startupdatinglocation];
iOS 8:location Services not working (iOS 8 location failed)