iOS8 无法自动定位城市
来源:互联网 发布:剑桥少儿英语软件下载 编辑:程序博客网 时间:2024/04/30 17:19
在IOS8中定位功能新增了两个方法:
- (void)requestWhenInUseAuthorization __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_8_0);
- (void)requestAlwaysAuthorization __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_8_0);这两个新增的方法导致之前写的自动定位的程序,在iOS8上无法正常使用。
这样让iOS8正常使用定位功能呢?
<1>你需要在info.plist表里面添加两条变量
在Info.plist中加入两个缺省没有的字段
NSLocationAlwaysUsageDescription
NSLocationWhenInUseUsageDescription
这两个字段没什么特别的意思,就是自定义提示用户授权使用地理定位功能时的提示语。
这样再写代码:
-(void)startLocation{ 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; }}
0 0
- iOS8 无法自动定位城市
- iOS8 定位当前城市
- 定位城市+iOS8 定位问题
- 关于iOS8无法定位
- 关于iOS8无法定位
- iOS8无法定位问题解决方案
- GPS自动定位,城市选择器
- IOS8 解决定位服务无法使用
- IOS8无法启用定位的服务:CLLocationManager
- IOS8下,百度地图无法定位解决办法
- JavaScript实时全国天气 ,自动定位城市
- IOS8定位
- iOS8定位
- IOS8定位
- iOS8定位
- IOS8 定位
- iOS8 高德地图SDK MAMapView无法定位的问题
- iOS8 高德地图SDK MAMapView无法定位的问题
- It is indirectly referenced from required .class files(导入项目报错原因与解决方法)
- linux下if语句的使用
- Linux 目录命令全称
- 解决gnome-shell下龙井内核wineqq提示信息残留过多的问题
- poj1006
- iOS8 无法自动定位城市
- 开博了
- 如何清空结构体?
- Jcseg分词 介绍
- linux定时任务二
- struts2中使用ModelDriven
- 今天用VS2005编译DirectShow程序,一些莫名其妙的问题总结
- 程序设计作业上机实践项目二
- Unity3D自带地形系统的创建与简单设置图文详解