添加纬度和经度值时出现问题
当我更改另一个位置的纬度和经度值时,我的应用程序自动关闭有帮助吗?
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"];
}
when i change the latitude and longitude value of another location my app closes automatically help ?
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"];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如 Twelve47 所说,您应该完全实现 委托,因为这两种方法都不是可选的。
听起来您只实现了成功方法:
–reverseGeocoder:didFindPlacemark:
,因此当您将位置更改为无法进行地理编码的某个位置时,会调用失败方法,从而导致错误。
添加此代码:
As Twelve47 Said, you should fully implement the delegate, since both methods are not optional.
It sounds like you have only implemented the sucess method:
– reverseGeocoder:didFindPlacemark:
so when you change the location to somewhere than cant be geocoded, the fail methods gets called which causes a error.
Add this code: