locationManager 定位地址不准,获取回调更准的方法
来源:互联网 发布:算法工程师是程序员吗 编辑:程序博客网 时间:2024/05/17 04:38
原来的写法,这种写法获取第一次返回的结果,然后就会停止更新经纬度
- (void)operationLocations:(NSArray *)locations{ [self.locationManager stopUpdatingLocation]; .... ....}- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations [self operationLocations:locations];}
猜想:LocationManager 定位回调会多次回调,及多次纠偏。所以,如果是最后一次,则是最准确的。
了解到:
// 延迟0.2s执行,如果有新任务,则取消原先的任务。最终只执行最后一次任务。
[[self class] cancelPreviousPerformRequestsWithTarget:self selector:@selector(todoSomething:) object:sender];
[self performSelector:@selector(todoSomething:) withObject:sender afterDelay:0.2f];
于是新写法如下:
- (void)operationLocations:(NSArray *)locations{ [self.locationManager stopUpdatingLocation]; .... ....}- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{ [[self class] cancelPreviousPerformRequestsWithTarget:self selector:@selector(operationLocations:) object:locations]; [self performSelector:@selector(operationLocations:) withObject:locations afterDelay:0.2f];}
0 0
- locationManager 定位地址不准,获取回调更准的方法
- 解决“locationManager.removeUpdates()关闭不了gps定位”的方法
- LocationManager的位置获取
- 浅析LocationManager的位置定位
- android中使用LocationManager定位获取信息
- 定位LocationManager
- LocationManager定位
- Location:LocationManager的位置获取
- 获取自己的经纬度 LocationManager
- selenium使用Xpath+CSS+JavaScript+jQuery的定位方法(专治各种定位不准并发症)
- 定位的第三方框架 LocationManager
- 基于LocationManager的定位工具类
- keil3 鼠标定位不准问题解决方法
- 定位内存地址的方法
- LocationManager定位获取经纬度并且转换成城市
- Android LocationManager定位之获取经纬度以及城市信息
- android GPS定位(locationmanager,高德,百度)定位的比较
- 去掉jbuider光标定位不准的解决办法
- Oracle学习笔记(2)------------体系结构2
- 收藏网站75
- 2012年5月SAT香港真题解析
- maven surefire plugin介绍
- Node.js Events模块
- locationManager 定位地址不准,获取回调更准的方法
- ZOJ Problem Set - 1048 Financial Management
- 华为荣耀3X root后不可写问题解决
- 收藏网站76
- 全选,不选,输出选中的值
- 【Android】Android之搭建开发环境(eclipse)
- 设计模式原则总结
- GRE写作必备句型
- C++程序编译过程简介