【问题标题】:Problem in adding latitude and longitude value添加纬度和经度值的问题
【发布时间】:2011-04-07 17:52:22
【问题描述】:

当我更改另一个位置的纬度和经度值时,我的应用会自动关闭帮助吗?

if (1)
{
    CLLocationCoordinate2D cordi;
    cordi.latitude  =  45.574779;
    cordi.longitude = -122.685366;

    MKReverseGeocoder *coder = [[MKReverseGeocoder alloc] initWithCoordinate:cordi];
    coder.delegate = self;
    [coder start];
}
else
{
    [self performSelectorInBackground:@selector(showWeather:) withObject:@"97217"];
}

【问题讨论】:

  • 您是否在控制台中收到错误消息或堆栈跟踪?查看 Apple 的示例应用程序CurrentAddress,了解他们如何声明、创建和使用 MKReverseGeocoder。
  • 您是否为 reverseGeocoder:didFailWithError: 和 reverseGeocoder:didFindPlacemark: 定义了方法?

标签: iphone ios coordinates cllocationmanager mkreversegeocoder


【解决方案1】:

正如 Twelve47 所说,您应该完全实现 delegate,因为这两种方法都不是可选的。

听起来你只实现了 sucess 方法:

– reverseGeocoder:didFindPlacemark:

因此,当您将位置更改为无法进行地理编码的某个位置时,会调用失败方法,从而导致错误。

添加此代码:

- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error
   NSLog(@"Geocoder failed with error: %@",error);
}

【讨论】:

    猜你喜欢
    • 2017-12-05
    • 1970-01-01
    • 2011-10-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-26
    • 1970-01-01
    • 2011-09-05
    • 1970-01-01
    相关资源
    最近更新 更多