UIlael lab_Area;
-(void)getUserCurrentAddress
{CLGeocoder *geoCoder=[[CLGeocoder alloc]init];
AppDelegate *delegate=(AppDelegate *)[UIApplication sharedApplication].delegate;
CLLocation *mycurLocaton=[[CLLocation alloc]initWithLatitude:delegate.currentCoordinate.latitude longitude:delegate.currentCoordinate.longitude];
//反解析
[geoCoder reverseGeocodeLocation:mycurLocaton completionHandler:^(NSArray *places,NSError *error){
CLPlacemark *aPlace=[places objectAtIndex:0];
if (aPlace.name==nil) {
[lab_Area setText:@"无法获取信息"];
}else
{
[lab_Area setText:aPlace.name];
}
[geoCoder release];
[mycurLocaton release];
}];
}
本文详细介绍了如何在iOS应用中使用Core Location框架获取当前地理位置,并通过CLGeocoder类进行地址反解析,最终在界面上展示获取到的地区名称。
3763

被折叠的 条评论
为什么被折叠?



