标签:des io os 使用 ar sp art on c
如果是xcode6和ios 8的话,需要调用 CLLocationManager requestAlwaysAuthorization 方法,具体步骤如下:
1. @interface里:
CLLocationManager *locationManager;
2. 初始化:
locationManager = [[CLLocationManager alloc] init];
3. 调用请求:
[locationManager requestAlwaysAuthorization];
[locationManager startUpdatingLocation];
4. 在 info.plist里加入:
NSLocationWhenInUseDescription,允许在前台获取GPS的描述
NSLocationAlwaysUsageDescription,允许在后台获取GPS的描述
ps:调用请求前加上ios版本判断就完美了。
完美一下:
// 判斷是否 iOS 8
if([self.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) {
[self.locationManager requestAlwaysAuthorization]; // 永久授权
[self.locationManager requestWhenInUseAuthorization]; //使用中授权
}
[self.locationManager startUpdatingLocation];
IOS-iOS 8 : Location Services not working(iOS 8 定位应用定位失败)
标签:des io os 使用 ar sp art on c
原文地址:http://www.cnblogs.com/tx8899/p/3989087.html