首页 > 移动平台 > 详细

iOS8定位问题解决方案

时间:2014-10-13 21:28:18      阅读:343      评论:0      收藏:0      [点我收藏+]

1、修改info

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

应用程序说明参见微信:
bubuko.com,布布扣

2、CLLocationManager初始化

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

if([CLLocationManager locationServicesEnabled]){
        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;
    }

}




iOS8定位问题解决方案

原文:http://blog.csdn.net/nextstudio/article/details/40050095

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!