iPhone开发应用中CoreLocation定位学习笔记
来源:互联网 发布:嫁给外国人 知乎 编辑:程序博客网 时间:2024/06/05 16:06
本文介绍的是iPhone开发应用中CoreLocation定位的内容,iPhone可以使用CoreLocation框架确定他的物理位置,可以利用三种技术来实现该功能:GPS,WiFi定位和蜂窝基站三角网定位。
AD
:
iPhone开发应用中CoreLocation定位学习是本文要介绍的内容,iPhone可以使用CoreLocation框架确定他的物理位置,可以利用三种技术来实现该功能:GPS,WiFi定位和蜂窝基站三角网定位。但在程序中我们只需设定我们希望的精度级别,由CoreLocation决定采用哪种技术可以更好的满足我们的请求。
1、位置管理器
- CLLocationManager *locationManager = [[CLLocationManager alloc] init];//创建位置管理器
- locationManager.delegate=self;//设置代理
- locationManager.desiredAccuracy=kCLLocationAccuracyBest;//指定需要的精度级别
- locationManager.distanceFilter=1000.0f;//设置距离筛选器
- [locationManager startUpdatingLocation];//启动位置管理器
2、位置管理器代理
主要的代理方法有两个
- //确定当前位置和位置更新了时调用这个方法
- - (void)locationManager:(CLLocationManager *)manager
- didUpdateToLocation:(CLLocation *)newLocation
- fromLocation:(CLLocation *)oldLocation
- {
- NSString *latitudeString=[[NSString alloc] initWithFormat:@"%g",newLocation.coordinate.latitude];
- //latitudeLabel.text=latitudeString;
- [latitudeString release];
- NSString *longitudeString=[[NSString alloc] initWithFormat:@"%g",newLocation.coordinate.longitude];
- //longitudeLabel.text=longitudeString;
- [longitudeString release];
- }
- //位置查询遇到错误时调用这个方法
- (void)locationManager:(CLLocationManager *)manager
- didFailWithError:(NSError *)error
- {
- NSString *errorType = (error.code == kCLErrorDenied) ?
- @"Access Denied" : @"Unknown Error";
- UIAlertView *alert = [[UIAlertView alloc]
- initWithTitle:@"Error getting Location"
- message:errorType
- delegate:nil
- cancelButtonTitle:@"Okay"
- otherButtonTitles:nil];
- [alert show];
- [alert release];
- }
小结:iPhone开发应用中CoreLocation定位学习笔记的内容介绍完了,希望本文对你有所帮助。
from:http://mobile.51cto.com/iphone-282956.htm
- iPhone开发应用中CoreLocation定位学习笔记
- CoreLocation定位学习笔记
- iPhone开发之CoreLocation定位功能(6)
- iOS学习笔记 地图(一)定位CoreLocation
- iOS学习笔记19-地图(一)定位CoreLocation
- iOS开发 - CoreLocation地理定位
- iOS开发 -- CoreLocation实现定位
- iOS8中使用CoreLocation定位
- iOS8中使用CoreLocation定位
- iOS8中使用CoreLocation定位
- iOS8中使用CoreLocation定位
- iOS8中使用CoreLocation定位
- iOS8中使用CoreLocation定位
- iOS8中使用CoreLocation定位
- iOS8中使用CoreLocation定位
- iOS8中使用CoreLocation定位
- iOS8中使用CoreLocation定位
- iOS8中使用CoreLocation定位
- DELPHI目录操作示例
- Qt学习之路(34): 国际化(下)
- Delphi_Format函数用法
- paip.防止代码命名重复的好方法
- 用IdTCPServer和IdTCPClient传输文件
- iPhone开发应用中CoreLocation定位学习笔记
- QPixmap与QImage的区别
- 5 ByteArrayInputStream 与 ByteArrayOutputStream类
- ACM计算几何题目推荐
- Toast显示图片提示
- 第一篇,关于Qt4+opencv实现打开摄像头和拍照功能(整理更正版)
- 6 字符编码
- ACM博弈题目总结
- ThreadLocal的解析