中易网

iOS8 根据经纬度显示地名

答案:1  悬赏:30  
解决时间 2021-10-28 18:59
iOS8 根据经纬度显示地名
最佳答案
我们很多时候做项目的时候都选用通过手机获取定位,然后传数据给后台,这是iOS8根据经纬度显示地名的demo   //1.导入框架   //   // NearByViewController.m   // nearDemo   //   // Created by apple on 14/12/5.   // Copyright (c) 2014年 youdianshang. All rights reserved.   //   #import   #import   {   NSUserDefaults *defaluts;   NSString * jingduStr;   NSString *weiduStr;   NSString *LocationAddress;   }   @property(nonatomic,retain)CLLocationManager *locationManager;   @property(strong,nonatomic)UILabel *positionLabel;      -(void)getLocationAll   {   self.locationManager = [[CLLocationManageralloc]init];   _locationManager.delegate =self;   _locationManager.desiredAccuracy =kCLLocationAccuracyBest;   _locationManager.distanceFilter =10;   [_locationManagerrequestAlwaysAuthorization];//添加这句   [_locationManagerstartUpdatingLocation];   }   /*   //通过经纬度得到当前地理位置   -(void)change{   defaluts=[NSUserDefaultsstandardUserDefaults];   CLLocationCoordinate2D coordinate;   coordinate.latitude = [[NSStringstringWithFormat:@%@,jingduStr]floatValue];   coordinate.longitude = [[NSStringstringWithFormat:@%@,weiduStr]floatValue];   CLLocation *newLocation=[[CLLocationalloc]initWithLatitude:coordinate.latitudelongitude: coordinate.longitude];   CLGeocoder *geocoder=[[CLGeocoderalloc] init];   [geocoder reverseGeocodeLocation:newLocationcompletionHandler:^(NSArray* placemarks,NSError* error)   {   MKPlacemark*placemark = [placemarks objectAtIndex:0];   LocationAddress = [NSStringstringWithFormat:@%@%@%@%@, placemark.locality, placemark.subLocality,placemark.thoroughfare, placemark.subThoroughfare];   [defaluts setObject:LocationAddress forKey:@address];   NSLog(@终极目标:1:[emailprotected]:[emailprotected]:[emailprotected]:%@, placemark.locality, placemark.subLocality,placemark.thoroughfare,placemark.subThoroughfare);   }];   #pragma mark--实现CLLocationManagerDelegate的代理方法,获取地理位置(镔)===========================================================================   //(1)获取到位置数据,返回的是一个CLLocation的数组,一般使用其中的一个   - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations   {   CLLocation *currLocation = [locations lastObject];   NSLog(@经度=%f纬度=%f高度=%f, currLocation.coordinate.latitude, currLocation.coordinate.longitude, currLocation.altitude);   jingduStr =[NSStringstringWithFormat:@%f, currLocation.coordinate.latitude];   weiduStr =[NSStringstringWithFormat:@%f, currLocation.coordinate.longitude];   NSLog(@jijijijijij:%@,jingduStr);   [self change];   }   //(2)获取用户位置数据失败的回调方法,在此通知用户   - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error   {   if ([error code] ==kCLErrorDenied)   {   //访问被拒绝   }   if ([errorcode] == kCLErrorLocationUnknown) {   //无法获取位置信息   }   }
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
你好 要是做水泥胶砂流动度实验时 用225的
食品的广告词有哪些
桑普有扳平了
请问秋天到了,我的手开始蜕皮了是怎么回事?挺
五岁半的宝宝吃奶粉好还是纯牛奶好?
赤峰有几家上海大众特约维修
上海佳程广场楼盘详情谁了解
韩国鞍山离东大门有多远?
泡沫剧与泡菜剧的区别
缺钙或钙不吸收怎么办呢?我在怀孕期间一直是
福建福州志高空调售后维修服务怎么样?
女性老年人夜尿多是怎么回事?
柏尔地板怎么样,柏尔地板的售后服务如何?
led户外灯具外壳佛山哪家做的好?
求兰州到夏河拉不楞开车路线
推荐资讯
济宁市有美发培训学校吗?
常年吃素食对身体有影响吗? 常年吃素食对身
请问各位大师们.组合布衣柜上的塑料三通四通
玉溪的房价还会涨吗?
宝宝六个月拉肚子拉了3个月最久可以吃多少天
薏米炖排骨汤可以喝吗
荣事达养生电炖盅RS-F12怎么用
王者之冠英语怎么写
中国银行合肥凤凰城支行周日营业吗
先天性孤独症怎么办?
装修客厅卧室一体要注意什么?
南充窗帘哪里买好看?
手机登qq时,显示手机磁盘不足,清理后重新登
刺客的套装怎么选啊?