gpt4 book ai didi

iphone - MKMapView 中可能存在的错误

转载 作者:可可西里 更新时间:2023-11-01 03:55:29 25 4
gpt4 key购买 nike

如果我创建一个带有 map View 的 ViewController,这是我添加到 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>

如果我将代码更改为这样,那么我不会收到任何错误:

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

唯一的区别是 (0,0) 在 map 中可见,而 (-90, -180) 在 map 之外。也就是说,我需要平移 map 以显示坐标 (-90, -180)。

有没有人以前遇到过这个错误,或者知道如何修复它?

最佳答案

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

关于iphone - MKMapView 中可能存在的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6804900/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com