mkmapview 在 IOS 4.2 中崩溃
这是卡提克。当我运行我的应用程序时,出现以下错误。当我的应用程序尝试查找用户位置时,它崩溃了。实际上在IOS 4.0和4.1中它工作得很好。只有在 4.2 中才会崩溃。你能帮助我吗?
CoreAnimation:忽略异常: (null) 必须在以下情况下实现标题 canShowCallout 对应的值为 YES 查看>可见:0 +0.00000000, +0.00000000 2011-05-09 12:32:40.631 HOV[1821:207] * 由于未捕获而终止应用程序 异常“NSGenericException”, 原因:'> 可见:0 +38.91791916, -77.20580292 必须实施标题时 canShowCallout 对应的值为 YES 查看>可见:0 +38.91791916,-77.20580292' *第一次抛出时的调用堆栈:
This is karthik. I am getting this following error when i run my application. When my application trying to find the user location its crashing. Actually in IOS 4.0 and 4.1 its working fine. Only in 4.2 its crashing. Can you help me?
CoreAnimation: ignoring exception:
(null) must implement title when
canShowCallout is YES on correspoding
view > visible:0 +0.00000000, +0.00000000 2011-05-09 12:32:40.631 HOV[1821:207] *
Terminating app due to uncaught
exception 'NSGenericException',
reason: '>
visible:0 +38.91791916, -77.20580292
must implement title when
canShowCallout is YES on correspoding
view > visible:0 +38.91791916, -77.20580292'
* Call stack at first throw:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您应该完全按照错误文本告诉您的操作:您的 MkAnnotation 委托应该实现
方法,该方法提供要在标注视图中显示的文本。
该方法是可选的,仅当将 canShowCallout 设置为 YES 时才会调用。
You should do exactly what the error text tells you to: your MkAnnotation delegate should implement
method, which provides the text to be shown in the callout view.
The method is optional and is called only if you set canShowCallout to YES.
检查注释视图中的标题。我认为标题有时被设置为空......
Check the title in the annotation view. I think title is set to null some times...
检查绘制的所有注释。我认为存在一种情况,注释没有标题会导致此崩溃。检查所有注释是否都有标题值。
Check all the annotations that are plotted. I think there is a case where an annotation does not have a title which leads to this crash. Check if all the annotations have values for title.
我在 iOS 4.2.1 上运行时遇到了同样的错误。该应用程序在 iOS 5.x 上没有崩溃。我还确保注释使用了所有已实现的
title
方法。事实证明,当时传递给
selectAnnotation:animated:
的注释为 nil。这解释了为什么错误消息提到(null)。即使未定义注释,iOS 4.2.1 也会检查
title
方法。因此,通过在调用
selectAnnotation:animated:
之前确保注释不为零来解决此问题。I got the same error when running on iOS 4.2.1. The app did not crash on iOS 5.x. I also made sure that the Annotations used all implemented
title
method.It turned out that the annotation passed to
selectAnnotation:animated:
was nil at that time.This explains why the error message mentions (null). iOS 4.2.1 appears to check for the
title
method even if the annotation is not defined.So this was fixed by making sure annotation was not nil before calling
selectAnnotation:animated:
.我有类似的问题。就我而言,方法
-(MKAnnotationView *)mapView:(MKMapView *)mView viewForAnnotation:(id)ann{ }
被调用两次。所以我将以下对我有用的代码放在那里:I had a similar problem. In my case the method
-(MKAnnotationView *)mapView:(MKMapView *)mView viewForAnnotation:(id<MKAnnotation>)ann{ }
was being called twice. So I put the following code there which worked for me: