定位适配iOS 8
来源:互联网 发布:网民网络素养 编辑:程序博客网 时间:2024/05/16 06:55
iOS 8 定位增加了WhenInUse(使用中可用) 和Always(一直可用)。
1. 对应增加了两个请求权限的方法:
- (void)requestWhenInUseAuthorization __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_8_0);- (void)requestAlwaysAuthorization __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_8_0);
2. Info.plist中增加了两个属性
<key>NSLocationAlwaysUsageDescription</key><string>YES</string><key>NSLocationWhenInUseUsageDescription</key><string>YES</string>
配合代理方法(参考资料1中说是新增的方法,其实不是新增的):
/* * locationManager:didChangeAuthorizationStatus: * * Discussion: * Invoked when the authorization status changes for this application. */- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_2);
代码中修改:
//iOS 8- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status{ switch (status) { case kCLAuthorizationStatusNotDetermined: //用户还没有选择是否授权 if ([self.lm respondsToSelector:@selector(requestAlwaysAuthorization)]) { [self.lm requestAlwaysAuthorization]; } break; case kCLAuthorizationStatusAuthorizedAlways: case kCLAuthorizationStatusAuthorizedWhenInUse: //有定位权限,开始定位,并计时 [self.delegate gpsStartLocating]; break; default: //没有定位权限,提示 [self.delegate gpsLocatedFailed]; break; } }
参考资料:
http://www.cocoachina.com/bbs/read.php?tid=217107&page=1&toread=1#tpc
http://zhidao.baidu.com/link?url=VcCcvHzH_4OsYr_-9_TsgIQue0N6YuI0awbdkVXjFl70tpNbPqRYu2av08jKsCGK4bsDb-vnI-f_7l_Zm096jd-C6NsKEnJLcSrDIn1henO
0 0
- 定位适配iOS 8
- ios 8 地图定位
- IOS 8 定位
- ios 8使用定位
- IOS 8 定位失败问题
- iOS 8 无法定位问题
- iOS 9适配系列教程:后台定位
- iOS 9适配系列教程:后台定位
- iOS 9适配系列教程:后台定位
- iOS 9适配系列教程:后台定位
- iOS 9适配系列教程:后台定位
- iOS 9适配系列教程:后台定位
- IOS定位
- IOS定位
- IOS 定位
- iOS定位
- ios 定位
- IOS 定位
- android 资源网站
- 【JAVA笔记——术】JAVA LIST DEL遍历方式研究
- Android 通过adb shell am broadcast发送广播
- ios如何加粗字体
- Openstack中OVS实现GRE网络的GRE数据包分析
- 定位适配iOS 8
- #devopstools 用DD测试磁盘读写速度
- CSS3的calc()使用
- 仿函数(函数对象)和STL算法
- 【BZOJ 3757】 苹果树
- HDU 4691 The Unsolvable Problem 后缀数组
- Android Studio 学习之路
- ubuntu安装anaconda
- 系统架构与任务功能的分解