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

关于升级到iOS8地图定位问题

2014-12-06 14:50 411 查看
转载http://blog.sina.com.cn/s/blog_8be86ad30102v1r0.html

正确让ios8定位的方法来了:

1.在Info.plist表里面添加两个变量

NSLocationAlwaysUsageDescription

NSLocationWhenInUseUsageDescription

(这两个字段没什么特别的意思,就是自定义提示用户授权使用地理定位功能时的提示语)

2.添加代码:

CLLocationManager *locationManager
= [[CLLocationManager alloc]init];


locationManager.delegate = self;

[locationManager requestAlwaysAuthorization];

locationManager.desiredAccuracy = kCLLocationAccuracyBest;

locationManager.distanceFilter = kCLDistanceFilterNone;

[locationManager startUpdatingLocation];

调用代理:

- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status {

switch (status) {

case kCLAuthorizationStatusNotDetermined:

if ([locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) {

[locationManager requestWhenInUseAuthorization];

}

break;

default:

break;

}

}

3.这样就可以打开地图定位功能了!

最近在做基于百度Map定位及路线轨迹的功能!完成后,也发出来供大家学习使用,尽情期待吧~



(后续)

最近手机升级到ios8以上,发现地图又无法定位了!


各种求救,最后找到解决方法!


ios8对定位做了一些调整,

1.@interface里:

CLLocationManager *locationManager;

2.locationManager=[[CLLcationManager alloc]init];

if([[[UIDevice currentDevice]systemVersion]doubleValue]>8.0)

{

[locationManager requestWhenInUseAuthorization];

}

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