标签:des style blog http io ar color os 使用
今天在开发的时候发现了一个iOS8的定位问题,执行操作之后,不会调用到定位之后的delegate方法中,然后找了一些资料来了解了一下ios8系统下的定位,发现确实是有所不同的:
解决方法:
1.在info.plist中添加key;
NSLocationWhenInUseDescription,允许在前台获取GPS的描述
NSLocationAlwaysUsageDescription,允许在后台获取GPS的描述
2.在代码定位中,做版本区分和授权请求:
if ([CLLocationManager locationServicesEnabled]) { if (!self.locationManager) { self.locationManager = [[CLLocationManager alloc] init]; } self.locationManager.delegate = self; self.locationManager.distanceFilter=1.0; self.locationManager.desiredAccuracy = kCLLocationAccuracyBest; if([self.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) { [self.locationManager requestAlwaysAuthorization]; // 永久授权 [self.locationManager requestWhenInUseAuthorization]; //使用中授权 } [self.locationManager startUpdatingLocation];//开启位置更新 self.delegate = delegate; }
标签:des style blog http io ar color os 使用
原文地址:http://blog.csdn.net/likendsl/article/details/41867197