系统定位在iOS8中的改变
CLLocationManager这个系统定位的类在iOS8之前要实现定位,只需要遵守CLLocationManagerDelegate这个代理即可:
- (void)startLocate
{
if([CLLocationManager locationServicesEnabled]){
_locManager = [[CLLocationManager alloc]init];
[self.locManager setDelegate:self];
[self.locManager setDesiredAccuracy:kCLLocationAccuracyBest];
[self.locManager startUpdatingLocation];
}
}
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
[_locManager stopUpdatingLocation];
CLLocation *currentLocation = [locations lastObject];
CLLocationCoordinate2D coor = currentLocation.coordinate;
NSString *latitude = @(coor.latitude).description;
NSString *longitude = @(coor.longitude).description;
}
iOS8之前以上两个方法正常的情况下,已经能够正常获取经纬度了。但是在iOS8下,则需要在startLocate这个方法中在CLLocationManager这个类实例化后添加如下代码:
if([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
[ self.locManager requestAlwaysAuthorization];
}
但是仅仅添加以上代码还不行,还需要在工程的info.plist文件中添加键值对:
Key Type Value
NSLocationAlwaysUsageDescription Array/Dictionary/Boolean/Data/Date/Number/String
注意上方对应的Type,这七种类型都支持,我重点说说String和Boolean类型:
1.Type为String时:Value这个地方开发者可以根据需要说明定位的具体目的,让用户清楚的知道开启定位后用于做什么,更加透明化,清晰化;

弹框中"定位"两字即为Type为String时Value设置的值为"定位"时的展示。
当Value的值为空时,弹框显示如下:

2.Type为Boolean时:Value填YES即可。弹框显示如下:

而iOS8以前,定位提示的弹框显示如下:

在iOS8下如果不做以上两处的处理,系统CLLocationManager这个类即时指定了代理,其获取经纬度的代理方法也不会走。
系统定位在iOS8中的改变的更多相关文章
- iOS8中定位服务的变化(CLLocationManager协议方法不响应,无法回掉GPS方法,不出现获取权限提示)
最近在写一个LBS的项目的时候,因为考虑到适配iOS8,就将项目迁移到Xcode6.0.1上,出现了不能正常获取定位服务权限的问题. self.manger = [[CLLocationManager ...
- iOS8中使用CoreLocation定位[转]
本文转自:http://blog.devzeng.com/blog/ios8-corelocation-framework.html iOS8以前使用CoreLocation定位 1.首先定义一个全局 ...
- iOS8中的定位服务
iOS8中的定位服务 My app that worked fine in iOS 7 doesn't work with the iOS 8 SDK. CLLocationManager doesn ...
- ios中关于系统定位CLLocationManager的使用解析
//1.添加定位管理委托协议 CLLocationManagerDelegate //2.初始化定位管理对象 self.locationManager=[[CLLocationManager allo ...
- iOS8中 UILocalNotification 和 UIRemoteNotification 使用注意
先说一个关于UILocalNotification的知识点,容易被忘记: Each app on a device is limited to 64 scheduled local notificat ...
- 描述了say_hello函数的具体内容,调用zend_printf系统函数在php中打印字符串
下载一个php的源代码包,这里使用的是php 4.0.5版,解压后会看到php的根目录下会有README.EXT_SKEL这样一个文件,打开详细阅读了一下,发现了一个非常好用的工具,这个工具可以帮你构 ...
- iOS 学习笔记 九 (2015.04.02)IOS8中使用UIAlertController创建警告窗口
1.IOS8中使用UIAlertController创建警告窗口 #pragma mark - 只能在IOS8中使用的,警告窗口- (void)showOkayCancelAlert{ NSSt ...
- ios8中的UIScreen
let orientation: UIInterfaceOrientation = UIApplication.sharedApplication().statusBarOrientation pri ...
- iOS8中添加的extensions总结(一)——今日扩展
通知栏中的今日扩展 分享扩展 Action扩展 图片编辑扩展 文件管理扩展 第三方键盘扩展 注:此教程来源于http://www.raywenderlich.com的<iOS8 by Tutor ...
随机推荐
- ios .a和.framework
创建Aggregate来合并模拟器和真机通用的framework 然后在Build Phases下New Run Script Phase创建合并脚本: # Constants SF_TARGET_N ...
- October 27th Week 44th Thursday 2016
The art of being wise is the art of knowing what to overlook. 智慧之道在于懂得该忽略什么. Always do your best. Wh ...
- iOS - 如何切图适配各种机型
关于iPhone6/6+适配问题一直有争议,今天小编专门为大家整理了相关的有效方案,希望对大伙儿有帮助! 移动app开发中多种设备尺寸适配问题,过去只属于Android阵营的头疼事儿,只是很多设计师选 ...
- Tensorflow 变量的共享
https://github.com/chenghuige/tensorflow-exp/blob/master/examples/sparse-tensor-classification/ tens ...
- ble示例代码
ble代码下载: https://github.com/sutogan4ik/Android-BLE-GATT-Master-Slave
- js简单的设置快捷键,hotkeys捕获键盘键和组合键的输入
设置快捷键 这是一个强健的 Javascript 库用于捕获键盘输入和输入的组合键,它没有依赖,压缩只有只有(~3kb). hotkeys on Githubhotkeys预览 创建 您将需要在您的系 ...
- list for循环中删除元素
Iterator.remove() is safe, you can use it like this: List<String> list = new ArrayList<> ...
- Project Euler欧拉计划
1 If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. Th ...
- Win10商店东方财富网 UWP版更新,支持平板,PC,手机
东方财富股份有限公司 近日向Win10商店提交了东方财富网V4.1版,这次为广大Win10平台用户带来了期待已久的桌面版本,可谓是良心厂商,值得鼓励和支持.4.1主要更新: 1. 支持桌面Window ...
- UWP Composition API - 锁定列的FlexGrid
需求是第一列锁定,那么怎么让锁定列不跟着滚动条向做移动呢? 其实很简单,让锁定列跟scrollviewer的滚动做反方向移动. 先看一下这个控件的模板,嗯,其实很简单,就是ListView的模板,不同 ...