【发布时间】:2012-03-19 14:14:36
【问题描述】:
我正在尝试通过 CLlocationManager 对象在 Xcode 中使用 coreloaction 框架获取当前位置名称。当我在我的 iPod touch 上测试我的应用程序时,CLlocationManager 为某些地方提供了价值,但为许多地方返回了 [null]。我该如何解决这个问题?帮我以下是编码。
-(void)viewDidLoad
{
self.locationManager = [[CLLocationManager alloc] init] ;
self.locationManager.delegate = self;
self.locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers;
[self.locationManager startUpdatingLocation];
}
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
CLGeocoder *geoCoder = [[CLGeocoder alloc]init];
[geoCoder reverseGeocodeLocation:newLocation completionHandler:^(NSArray *placemarks, NSError *error)
{
if(error)
{
NSLog(@"error:%@",[error localizedDescription ]);
NSLog(@"Check your inetconnection");
}
_placedetail=nil;
self.placedetail=[placemarks objectAtIndex:0];
self.Label.text=self.placedetail.locality;
}];
[manager stopUpdatingLocation];//for stop process update
}
【问题讨论】:
标签: objective-c xcode4.2