[英]Dragging MKPinAnnotationView throws error
我有一個符合MKAnnotation類的AddressAnnotation類。 我使用MKReverseGeocoderDelegate方法從用戶位置獲取地址。 在那個代表中,我放下了別針。 我將圖釘設置為可拖動,然后在調用以下方法時,再次啟動反向地址解析器。
- (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上設置一個斷點,以在調試器中停止。這是當前的觀察信息:”
聽起來您創建了一個名為AddressAnnotation的MKAnnotation子類。 一個類正在通過鍵值觀察來觀察該類屬性的成員,並且AddressAnnotation實例已被釋放而未移除觀察者。 我認為您可以通過運行來解決此問題
- (void)removeObserver:(NSObject *)anObserver forKeyPath:(NSString *)keyPath
在釋放AddressAnnotation之前。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.