系统定位在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 ...
随机推荐
- Echarts 3.19 制作常用的图形 非静态
最近阿里内部使用的 图表也向外开放了 而百度就好像更有良心一点,Echarts 早就开放了 . 自己学Echarts的时候走了很多的弯路,毕竟谁让自己菜呢,多撞几次南墙才晓得疼 才知道学习方法,新手上 ...
- Oracl中sql书写技巧
1.写脚本(1)为什么不直接设置回滚点?因为服务器上数据库是很多人使用的,所以除了自己操作外,有很多人操作.如果设置回滚点时,回滚后,很多人操作都消失了,因此savepoint不可以.但是可以自己书写 ...
- mysql事务
1. 事务并不专属于mysql 2. 事务的ACID特性 1)原子性(atomicity) 一个事务必须被视为一个不可分割的最小工作单元,整个事务中得所有操作要么全部提交成功,要么全部失败回滚,对于一 ...
- 大数据系列-java用官方JDBC连接greenplum数据库
这个其实非常简单,之所以要写此文是因为当前网上搜索到的文章都是使用PostgreSQL的驱动,没有找到使用greenplum官方驱动的案例,两者有什么区别呢? 一开始我也使用的是PostgreSQL的 ...
- Objective-C歌词解析
#import <Foundation/Foundation.h> int main(int argc, const char * argv[]) { FILE* fp1;//定义文件指针 ...
- Python中的网络编程
TCPServer端: __author__ = 'Nature' # -*- coding: utf-8 -*- from socket import * from time import ctim ...
- AngularJs学习
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...
- Android应用请求获取Root权限
应用获取Root权限的原理:让应用的代码执行目录获取最高权限.在Linux中通过chmod 777 [代码执行目录] /** * 应用程序运行命令获取 Root权限,设备必须已破解(获得ROOT权限) ...
- swift 命令
http://blog.chinaunix.net/uid-15063109-id-5144658.html http://www.cnblogs.com/fczjuever/p/3224022.ht ...
- echarts中显示效果option中必有的属性
写一个最简单的效果让option中不可缺少的属性. var option = { xAxis:[ //x轴,数组对象,其下至少有一个对象 {.....} ], yAxis:[//y轴,数组对象,其下可 ...