iOS將地址解析成經(jīng)緯度的方法
更新時間:2017年08月15日 11:09:37 作者:弦外雨
這篇文章主要為大家詳細(xì)介紹了iOS將地址解析成經(jīng)緯度的方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了iOS將地址解析成經(jīng)緯度的具體代碼,供大家參考,具體內(nèi)容如下
一、工程圖
二、代碼
ViewController.h
#import <UIKit/UIKit.h> #import <CoreLocation/CoreLocation.h> #import <CoreLocation/CLLocationManagerDelegate.h> @interface ViewController : UIViewController <CLLocationManagerDelegate> @end
ViewController.m
#import "ViewController.h" #import <CoreLocation/CoreLocation.h> #import <AddressBook/AddressBook.h> //正編譯。將地址解析為經(jīng)緯度 @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. CLGeocoder *geocoder = [[CLGeocoder alloc] init]; [geocoder geocodeAddressString:@"上海徐匯漕溪路" completionHandler:^(NSArray *placemarks, NSError *error){ NSLog(@"查詢記錄數(shù):%ld",[placemarks count]); if ([placemarks count] > 0) { CLPlacemark *placemark = [placemarks objectAtIndex:0]; CLLocationCoordinate2D coordinate = placemark.location.coordinate; NSString *strCoordinate = [NSString stringWithFormat:@"經(jīng)度:%3.5f 緯度:%3.5f:",coordinate.latitude,coordinate.longitude ]; NSLog(@"%@",strCoordinate); } }]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
iOS支付寶、微信、銀聯(lián)支付集成封裝調(diào)用(上)
本篇文章給大家分享了iOS支付寶、微信、銀聯(lián)支付集成封裝調(diào)用的相關(guān)代碼和實例,有興趣的朋友學(xué)習(xí)下。2018-04-04IOS開發(fā)中加載大量網(wǎng)絡(luò)圖片優(yōu)化方法
這篇文章主要介紹了IOS開發(fā)中加載大量網(wǎng)絡(luò)圖片如何優(yōu)化的相關(guān)資料,需要的朋友可以參考下2017-03-03IOS如何使用CAShapeLayer實現(xiàn)復(fù)雜的View的遮罩效果
這篇文章主要為大家詳細(xì)介紹了IOS如何使用CAShapeLayer實現(xiàn)復(fù)雜的View的遮罩效果,感興趣的小伙伴們可以參考一下2016-03-03使用objc runtime實現(xiàn)iOS閉環(huán)的懶加載功能
利用objc runtime的動態(tài)性實現(xiàn)懶加載可以實現(xiàn)即可增加又可刪除功能,也可以避免污染類型。這篇文章主要介紹了使用objc runtime實現(xiàn)iOS閉環(huán)的懶加載功能,需要的朋友可以參考下2019-06-06詳解使用Xcode進(jìn)行iOS設(shè)備無線調(diào)試
這篇文章主要介紹了詳解使用Xcode進(jìn)行iOS設(shè)備無線調(diào)試,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-12-12