我有一些引腳,用戶可以添加。在標註中有一個按鈕。 當用戶按下按鈕時,我想要一個新的引腳放在該位置,我想擺脫用戶按下的引腳(不同類型的引腳)。似乎無法刪除任何註釋
基本上第一個引腳是可拖動的,當用戶找到合適的位置時,它們將「鎖定」它。 (鎖定的引腳在幾種方式中的作用不同,這就是爲什麼我需要替換舊的引腳)
反正,這是我做我的處理的方法。當我到達[mapView removeAnnotation:view.annotation];我得到的部分是「節目接收信號:」EXC_BAD_ACCESS「。」
有人可以幫我嗎? (問題不在於新註釋沒有出現,因爲它確實出現了。問題是舊註釋不會消失)。 編輯:根據建議固定代碼。
- (void) mapView:(MKMapView *)MapView
annotationView:(MKAnnotationView *)view
calloutAccessoryControlTapped:(UIControl *)control {
LockedPotholeAnnotation *annotation = [[[LockedPotholeAnnotation alloc] initWithCoordinate:view.annotation.coordinate addressDictionary:nil]autorelease];
NSString *titleString = [NSString stringWithFormat:@"Pothole at %.4f, %.4f", view.annotation.coordinate.latitude, view.annotation.coordinate.longitude];
annotation.title = titleString;
[mapView addAnnotation:annotation];
//[annotation release];
NSLog(@"Added Pin");
NSLog(@"VA: %@", [view.annotation class]);
[mapView removeAnnotation:view.annotation];
//[mapView removeAnnotations:mapView.annotations];
[mapView setNeedsDisplay];
}
啊,我可以看到的錯誤。除此之外,我似乎沒有與新的註釋有關的問題。新的「鎖定」註釋出現,但舊的註釋並未消失,事實上這是問題。 – 2010-10-19 18:19:01
@DJ在這種情況下,很難說 - 代碼似乎沒有明顯錯誤,所以問題可能在其他地方。在嘗試刪除之前,檢查'view'中傳遞的是否確實是正確的,並且'view.annotation'在地圖視圖的'annotations'數組中。如果您在添加新註釋之前執行了刪除操作,那麼刪除操作是否有效?如果你根本不添加新的?當你刪除所有內容時會發生什麼,就像在註釋掉的行中一樣? ETC - 抱歉,我不能提出什麼比基本調試苦差事更有幫助... – walkytalky 2010-10-20 10:41:19
原來,在這裏我補充說明原來的地方,我也有額外的版本在那裏。當我嘗試刪除所述註釋時,它將其擰緊。刪除該線固定它。非常感謝。 – 2010-10-21 14:05:12