CoreLocation 中的 CLLocationManager
来源:互联网 发布:triz矛盾矩阵表 编辑:程序博客网 时间:2024/06/05 09:24
CoreLocation框架所包含的类,IOS应用可以通过它们获得设备的当前地理位置。而且不论用哪种类型的IOS需要编写的Core Location代码都是一样的。主要应用的两个类:
CLLocationManager
CLLocationManagerDelegate协议
1.将框架导入后,导入头文件,遵守该协议。
2.然后实例化一个CLLocationManager,主要步骤:
//初始化对象CLLocationManager *locManager = [CLLocationManager alloc] init];//设置委托[locManager setDelegate:self];//设置位置信息精度 这里的参数是要求不考虑时间和电力,返回尽可能精确的数据[locManager setDesiredAccuracy:kCLLocationAccuracyBest];//开始定位[locManager startUpdatingLocation];
3.既然实现了协议就要实现其中的委托方法
//查找位置成功时候的方法 - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocationfromLocation:(CLLocation *)oldLocation;//查询失败时候的方法- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error;
不过最后要补充一下,查找成功时实现的委托方法现在已经过时了,这是我从API里截的图:
从IOS6开始,苹果推荐使用didUpdateLocations方法了,传入一个NSArray参数。
- CoreLocation 中的 CLLocationManager
- IOS CoreLocation中CLLocationManager类的基本使用
- CLLocationManager
- 【iOS开发-109】CoreLocation框架的两个主要类CLLocationManager和CLGeoCoder介绍
- iOS CoreLocation框架第一章—— CLLocationManager的使用(包含iOS6,iOS8,iOS9各种变动)
- iOS中的定位-CoreLocation框架
- CoreLocation
- CoreLocation
- CoreLocation
- coreLocation
- mapview的定位与corelocation中的定位
- ios开发中的官方地图(CLLocationManager)使用
- 定位 (CLLocationManager )
- CLLocationManager 定位
- 定位CLLocationManager
- 定位 CLLocationManager
- CoreLocation 用法
- IOS CoreLocation
- bitbucket+goagent
- ejb2.0 HelloWord
- Android:实现手势滑动的事件处理方法
- 从SQLHelper看代码重构
- 【Android】基于andengine游戏引擎的简单游戏实现(模拟控制器、tiledmap地图)
- CoreLocation 中的 CLLocationManager
- PHP下添加PDO_Pgsql扩展
- oracle的控制文件(control file)
- Ubuntu12.04 LTE 下为Firefox安装Adobe Flash Player--个人成功经验
- 黑马程序员------java学习笔记之网络编程
- python(一)
- MyEclipse
- 再论节点Node与元素的区别
- 一道面试题:有一个整数数组,请求出两两之差绝对值最小的值,记住,只要得出最小值即可,不需要求出是哪两个数。