獲取當前經緯度方法
首先頭文件應繼承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