【问题标题】:Dragging MKPinAnnotationView throws error拖动 MKPinAnnotationView 抛出错误
【发布时间】:2011-09-20 03:40:07
【问题描述】:

我有一个符合 MKAnnotation 类的 AddressAnnotation 类。我使用 MKReverseGeocoderDelegate 方法从用户的位置获取地址。在那个代表中,我放下了别针。我将pin设置为可拖动,当调用下面的方法时,我再次启动反向地理编码器。

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view didChangeDragState:(MKAnnotationViewDragState)newState fromOldState:(MKAnnotationViewDragState)oldState {
    if (newState == MKAnnotationViewDragStateEnding) {
        CLLocationCoordinate2D newCoordinate = view.annotation.coordinate;
        MKReverseGeocoder *reverseGeocoder = [[MKReverseGeocoder alloc] initWithCoordinate:newCoordinate];
        reverseGeocoder.delegate = self;
        [reverseGeocoder start];
    }
}

它适用于大约 3 针拖动,直到我收到以下错误。我不确定这意味着什么或发生了什么。任何帮助,将不胜感激。谢谢!

“AddressAnnotation 类的实例 0x1b7ac0 已被释放,而键值观察者仍向其注册。观察信息被泄露,甚至可能被错误地附加到其他对象。在 NSKVODeallocateBreak 上设置断点以在调试器中停止。这是当前的观察信息:"

【问题讨论】:

    标签: iphone


    【解决方案1】:

    听起来您创建了一个名为 AddressAnnotation 的 MKAnnotation 子类。一个类正在使用键值观察来观察此类属性的成员,并且在未移除观察者的情况下释放了 AddressAnnotation 的实例。我认为您可以通过运行来解决此问题

    - (void)removeObserver:(NSObject *)anObserver forKeyPath:(NSString *)keyPath
    

    在 AddressAnnotation 发布之前。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-12-10
      • 2011-07-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多