您的位置:首页 > 移动开发 > IOS开发

iOS8定位问题解决方案

2015-08-03 15:23 316 查看
m

1、修改info

新增Key:NSLocationAlwaysUsageDescription和NSLocationWhenInUseUsageDescription,这两个Key的值将分别用于描述应用程序始终使用和使用期间使用定位的说明,这些说明将显示在用户设置中。
info新增键值对如下:





应用程序说明参见微信:



2、CLLocationManager初始化

iOS8CLLocationManager新增实例方法requestWhenInUseAuthorization和requestAlwaysAuthorization,需要在初始化时根据需要调用。



self.locationManage = [[[CLLocationManager alloc] init] autorelease];
self.locationManage.delegate = self;
self.locationManage.distanceFilter = 200;
self.locationManage.desiredAccuracy = kCLLocationAccuracyBestForNavigation;//kCLLocationAccuracyBest;
if (SYSTEM_VERSION >= 8.0) {
//使用期间
[self.locationManage requestWhenInUseAuthorization];
//始终
//or [self.locationManage requestAlwaysAuthorization]
}

3、代理

新增下面的代理方法:
- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
{
switch (status) {
case kCLAuthorizationStatusNotDetermined:
if ([self.locationManage respondsToSelector:@selector(requestAlwaysAuthorization)])
{
[self.locationManage requestWhenInUseAuthorization];
}
break;
default:
break;
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: