怀孕流产,济南建筑装饰信用网,深圳建国男科医院
本文实例为大家分享了ios将地址解析成经纬度的具体代码,供大家参考,具体内容如下
一、工程图
二、代码
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> //正编译。将地址解析为经纬度 @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(@"查询记录数:%ld",[placemarks count]); if ([placemarks count] > 0) { clplacemark *placemark = [placemarks objectatindex:0]; cllocationcoordinate2d coordinate = placemark.location.coordinate; nsstring *strcoordinate = [nsstring stringwithformat:@"经度:%3.5f 纬度:%3.5f:",coordinate.latitude,coordinate.longitude ]; nslog(@"%@",strcoordinate); } }]; } - (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of any resources that can be recreated. } @end
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
iOS 使用UITextField自定义搜索框 实现用户输入完之后“实时搜索”功能
网友评论