MKMapView中可能的错误

编程入门 行业动态 更新时间:2024-10-24 10:25:40
本文介绍了MKMapView中可能的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如果我使用地图视图创建ViewController,这是我添加到viewDidLoad的唯一代码:

If I create a ViewController with a map view and this is the only code I add to viewDidLoad:

MKPointAnnotation* annotation = [[MKPointAnnotation alloc] init]; annotation.coordinate = CLLocationCoordinate2DMake(-90, -180); [self.mapView addAnnotation:annotation]; [self.mapView removeAnnotation:annotation]; [annotation release];

我得到了错误:

An instance 0xa126fa0 of class MKPointAnnotation was deallocated while key value observers were still registered with it. Observation info was leaked, and may even become mistakenly attached to some other object. Set a breakpoint on NSKVODeallocateBreak to stop here in the debugger. Here's the current observation info: <NSKeyValueObservationInfo 0xa127df0> ( <NSKeyValueObservance 0xa127c90: Observer: 0xa11c530, Key path: coordinate, Options: <New: NO, Old: NO, Prior: YES> Context: 0x0, Property: 0xa127640>

如果我将代码更改为此,则不会出现任何错误:

If I change the code to this then I don't get any errors:

MKPointAnnotation* annotation = [[MKPointAnnotation alloc] init]; annotation.coordinate = CLLocationCoordinate2DMake(0, 0); [self.mapView addAnnotation:annotation]; [self.mapView removeAnnotation:annotation]; [annotation release];

唯一的区别是(0,0)在地图上可见,而(-90,-180)在视图之外.也就是说,我需要平移地图才能使坐标(-90,-180)可见.

The only difference is that (0,0) is visible in the map, where as, (-90, -180) is out of view. That is, I need to pan the map to bring coordinate (-90, -180) into view.

任何人都曾经历过此错误,甚至更好地知道如何解决该错误?

Anyone experienced this error before or even better know how to fix it?

推荐答案

经过更多测试后,我确信这是MKMapView中的错误.我通过仅添加可见区域中的注释来解决此问题.更多工作,但至少不会使我的应用程序崩溃:)

After some more testing I'm convinced it is a bug in MKMapView. I worked around it by only adding annotations that are in the visible region. More work but at least it doesn't crash my app :)

更多推荐

MKMapView中可能的错误

本文发布于:2023-11-26 21:05:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1635196.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   MKMapView

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!