iOS8 定位问题
2015-08-31 16:07
459 查看
http://www.th7.cn/Program/IOS/201409/282090.shtml
在IOS8中定位功能新增了两个方法:
这两个新增的方法导致,之前写的程序在iOS8运行会出现,定位功能无法正常使用
这样让iOS8正常使用定位功能呢?
<1>你需要在info.plist表里面添加两条变量
在Info.plist中加入两个缺省没有的字段
NSLocationAlwaysUsageDescription
NSLocationWhenInUseUsageDescription
这两个字段没什么特别的意思,就是自定义提示用户授权使用地理定位功能时的提示语。
这样在写代码:
这是在调用代理
这样就Ok了,就会弹出原来的提示框
在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
这两个字段没什么特别的意思,就是自定义提示用户授权使用地理定位功能时的提示语。
这样在写代码:
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; }}
这样就Ok了,就会弹出原来的提示框
相关文章推荐
- CSS浮动和定位学习笔记
- C#实现txt定位指定行完整实例
- JS option location 页面跳转实现代码
- JavaScript中的Location地址对象
- window.location不跳转的问题解决方法
- Flex中怎么给表格中的滚动条定位避免刷新回到原处
- JS location几个方法小姐
- 一个JavaScript操作元素定位元素的实例
- js中的如何定位固定层的位置
- 关于js中window.location.href,location.href,parent.location.href,top.location.href的用法与区别
- Oracle新建用户、角色,授权,建表空间的sql语句
- MySql增加用户、授权、修改密码等语句
- 远程连接mysql 授权方法详解
- 在WIN命令提示符下mysql 用户新建、授权、删除,密码修改
- JS教程:window.location使用方法的区别介绍
- JS弹出层单纯的绝对定位居中示例代码
- JavaScript网页定位详解
- javascript中的window.location.search方法简介
- IE下通过a实现location.href 获取referer的值
- sqlSQL数据库怎么批量为存储过程/函数授权呢?