我是 iOS 新手。我使用了这个答案中的代码:https ://stackoverflow.com/a/3999583/1572234
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)annotationView
didChangeDragState:(MKAnnotationViewDragState)newState
fromOldState:(MKAnnotationViewDragState)oldState
{
if (newState == MKAnnotationViewDragStateEnding)
{
NSLog(@"didChangeDragState");
}
}
- (void) mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)annotationView
{
if ([[annotationView.annotation title] isEqualToString:@"2nd"]||[[annotationView.annotation title] isEqualToString:@"3rd"])
{
NSLog(@"didSelectAnnotationView");
}
}
但是在我尝试拖动 pin 三次之后,我在调试区域看到了这个:
2012-08-05 14:47:06.962 TestApp[1692:11603] didSelectAnnotationView
2012-08-05 14:47:11.825 TestApp[1692:11603] didChangeDragState
2012-08-05 14:47:16.269 TestApp[1692:11603] didSelectAnnotationView
2012-08-05 14:47:20.205 TestApp[1692:11603] didChangeDragState
2012-08-05 14:47:20.207 TestApp[1692:11603] didChangeDragState
2012-08-05 14:47:24.033 TestApp[1692:11603] didSelectAnnotationView
2012-08-05 14:47:26.811 TestApp[1692:11603] didChangeDragState
2012-08-05 14:47:26.814 TestApp[1692:11603] didChangeDragState
2012-08-05 14:47:26.816 TestApp[1692:11603] didChangeDragState
我只需要一次调用 NSLog(@"didChangeDragState"),每次我拖动 pin 时,我错过了什么?帮助请。