【问题标题】:CLLocationManager return null for locality in XcodeCLLocationManager 在 Xcode 中为局部性返回 null
【发布时间】: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


    【解决方案1】:

    这个问题很久以前了。但我会在此处添加我的解决方案以供将来参考。

    我遇到了同样的问题。我认为它的发生是由于一些小城市的地图尚未更新。或局部冲突。为避免此崩溃,请尝试通过提供子位置进行错误处理。

    示例:如果位置不可用,请选择更大的行政区域。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-22
      • 1970-01-01
      • 2017-09-13
      • 1970-01-01
      • 1970-01-01
      • 2020-12-30
      相关资源
      最近更新 更多