我在IOS4 mapkit中有一个可拖动的注释,我试图在注释被拖动到一个新的位置时调用一个事件。annotationView didChangeDragState被多次触发
我的代码目前的样子:
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)annotationView
didChangeDragState:(MKAnnotationViewDragState)newState fromOldState:(MKAnnotationViewDragState)oldState
{
if (newState == MKAnnotationViewDragStateEnding)
{
CLLocationCoordinate2D droppedAt = annotationView.annotation.coordinate;
NSLog(@"dropped at %f,%f", droppedAt.latitude, droppedAt.longitude);
//update the annotation
//see if its an information annotation
if ([annotationView.annotation isKindOfClass:[InfoAnnotation class]]) {
NSLog(@"Info annotation updating..");
InfoAnnotation* userAnnotation = ((InfoAnnotation *)annotationView.annotation);
[userAnnotation updateLocationWithServerForConvoy: self.title];
}
}
}
代码只需登录更新,然后告诉标注其更新发送到我的服务器,这是一个自定义的方法。
这种方法似乎越来越开除多次,在这里看到的日志:
2011-06-15 01:12:39.347 Convoy[1699:207] dropped at 37.340206,-122.027550
2011-06-15 01:12:39.347 Convoy[1699:207] Info annotation updating..
2011-06-15 01:12:39.658 Convoy[1699:207] dropped at 37.340206,-122.027550
2011-06-15 01:12:39.659 Convoy[1699:207] Info annotation updating..
2011-06-15 01:12:39.957 Convoy[1699:207] dropped at 37.340206,-122.027550
2011-06-15 01:12:39.958 Convoy[1699:207] Info annotation updating..
2011-06-15 01:12:43.415 Convoy[1699:207] dropped at 37.339251,-122.026691
2011-06-15 01:12:43.416 Convoy[1699:207] Info annotation updating..
2011-06-15 01:12:43.713 Convoy[1699:207] dropped at 37.339251,-122.026691
2011-06-15 01:12:43.713 Convoy[1699:207] Info annotation updating..
2011-06-15 01:12:44.006 Convoy[1699:207] dropped at 37.339251,-122.026691
2011-06-15 01:12:44.006 Convoy[1699:207] Info annotation updating..
2011-06-15 01:12:44.297 Convoy[1699:207] dropped at 37.339251,-122.026691
2011-06-15 01:12:44.297 Convoy[1699:207] Info annotation updating..
2011-06-15 01:12:54.825 Convoy[1699:207] dropped at 37.337135,-122.025833
2011-06-15 01:12:54.825 Convoy[1699:207] Info annotation updating..
2011-06-15 01:12:55.150 Convoy[1699:207] dropped at 37.337135,-122.025833
2011-06-15 01:12:55.150 Convoy[1699:207] Info annotation updating..
2011-06-15 01:12:55.475 Convoy[1699:207] dropped at 37.337135,-122.025833
2011-06-15 01:12:55.476 Convoy[1699:207] Info annotation updating..
2011-06-15 01:12:55.771 Convoy[1699:207] dropped at 37.337135,-122.025833
2011-06-15 01:12:55.772 Convoy[1699:207] Info annotation updating..
2011-06-15 01:12:56.070 Convoy[1699:207] dropped at 37.337135,-122.025833
2011-06-15 01:12:56.070 Convoy[1699:207] Info annotation updating..
每次我将它拖到(即空白),它似乎加1的时候,它就是所谓的量。任何人都可以给我任何想法可能造成这种情况?
看起来我们是唯一的人这个问题。我的行为和你描述的完全一样。 我注意到,当拖动的注释是MKPinAnnotationView时,它工作正常,但如果您的注释是MKAnnotationView,则会出现问题。看起来非常像ios中的错误。 我会在苹果公司开一个。 也许你会想这样做,以获得更多的压力? – 2011-06-30 11:15:57