系统定位在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动画效果和实现
动画效果提供了状态或页面转换时流畅的用户体验,在iOS系统中,咱们不需要自己编写绘制动画的代码,Core Animation提供了丰富的api来实现你需要的动画效果. UIKit只用UIView来展示 ...
- Ajax文件上传
- MongoDB 安装及其配置
安装: 安装路径d:MongoDB较短便于后续操作 配置: 1.新建data文件夹并在data文件夹下新建db和log文件夹,路径如下 MongoDB\data\db MongoDB\data\log ...
- hdu 1241 Oil Deposits
#include<cstdio> #include<iostream> #include<algorithm> #include<math.h> #in ...
- 缓存淘汰算法--LRU算法
1. LRU1.1. 原理 LRU(Least recently used,最近最少使用)算法根据数据的历史访问记录来进行淘汰数据,其核心思想是"如果数据最近被访问过,那么将来被访问的几率也 ...
- sqlserver中BCP命令导入导出
个人自用导出文本文件命令: bcp [xxDB].[dbo].[xx_tb_name] out d:\temp\xxx.txt -c -t "\t" -T bcp是SQL Serv ...
- 基于Netty与RabbitMQ的消息服务
Netty作为一个高性能的异步网络开发框架,可以作为各种服务的开发框架. 前段时间的一个项目涉及到硬件设备实时数据的采集,采用Netty作为采集服务的实现框架,同时使用RabbitMQ作为采集服务和各 ...
- CA认证原理以及实现(上)
转自:http://yale.iteye.com/blog/1675344 原理基础数字证书为发布公钥提供了一种简便的途径,其数字证书则成为加密算法以及公钥的载体,依靠数字证书,我们可以构建一个简单的 ...
- 优化Linux内核参数
转自:http://www.centoscn.com/CentOS/config/2013/0804/992.html vim /etc/sysctl.conf 1.net.ipv4.tcp_max_ ...
- Ubuntu菜鸟入门(四)—— 搜狗输入法
一 搜狗输入法安装 1 下载安装包: http://pinyin.sogou.com/linux/ 2 安装安装包 (1)"GDebi",这是一个用于安装你自己手动下载包的 ...