获取当前经纬度方法
首先头文件应继承CLLocationManagerDelegate.并:#import <CoreLocation/CoreLocation.h>
响应事件中写如下代码:
CLLocationManager *_locManager = [[CLLocationManager alloc] init];
[_locManager setDelegate:self];
[_locManager setDesiredAccuracy:kCLLocationAccuracyBest];
[_locManager startUpdatingLocation];
重载
#pragma mark -
#pragma mark Location manager
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
CLLocationCoordinate2D loc = [newLocation coordinate];
NSString *lat =[NSString stringWithFormat:@"%f",loc.latitude];//get latitude
NSString *lon =[NSString stringWithFormat:@"%f",loc.longitude];//get longitude
NSLog(@"%@ %@",lat,lon);
}
最后更新:2017-04-02 22:16:01
上一篇:
解决myeclipse编辑js缓慢的问题
下一篇:
Android:ScrollView/HorizontalScrollView常用技巧
Python多线程下载有声小说
Cracking the Coding Interview:: 寻找有环链表的环路起始节点
阿里云E-MapReduce Spark 作业配置
你是否真的需要64位的JDK呢?你是根据什么来判断与决定呢?
android短信数据库监听回调多次问题
【Linux shell】sed实践(3)
Intellij IDEA中生成jar包
开源大数据周刊-第61期
CVE-2016-10190 FFmpeg Http协议 heap buffer overflow漏洞分析及利用
HTTP的请求头 Last-Modified 与 If-Modified-Since 和 If-None-Match 与 ETags