ios 7 MKMapView拖动式注释更改它在地图滚动时的位置
问题描述:
我正在更新我的应用程序(MyWorld)到iOS 7. 应用程序的一个功能之一是,您可以在地图视图上拖动销。 它似乎在iOS7中被破坏。ios 7 MKMapView拖动式注释更改它在地图滚动时的位置
步骤来重现问题:
- 添加注释到地图: - 工作正常
- 移动注释(拖动)工作正常
- 滚动地图:问题
每当我滚动地图vi新注释随地图移动。它似乎没有附加到正确的视图或图层?如果该引脚未被拖动,则地图视图看起来工作正常,并且注释保持在定义的位置。 我想知道这是我的错误还是已知的问题?
我创建的ilusstrates在GitHub上的问题,虚拟MapViewTest项目:https://github.com/DJMobileInc/MapViewTest
答
这是从MKAnnotationView Class Reference,对于MKAnnotationViewDragStateNone常数:
MKAnnotationViewDragStateNone
的观点是不参与在拖动操作中。注释视图负责在拖动结束或取消时自己返回到此状态。
要解决该问题,当注释结束或取消其拖动操作时,您的地图视图委托需要将注释视图的dragState设置回MKAnnotationViewDragStateNone。
例如:
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)annotationView
didChangeDragState:(MKAnnotationViewDragState)newState
fromOldState:(MKAnnotationViewDragState)oldState
{
if (newState == MKAnnotationViewDragStateEnding) {
// custom code when drag ends...
// tell the annotation view that the drag is done
[annotationView setDragState:MKAnnotationViewDragStateNone animated:YES];
}
else if (newState == MKAnnotationViewDragStateCanceling) {
// custom code when drag canceled...
// tell the annotation view that the drag is done
[annotationView setDragState:MKAnnotationViewDragStateNone animated:YES];
}
}
答
我有同样的问题,我解决它加入“setDragState”我MKAnnotationView类。
这是一个古老的解决方案,但它的工作对我来说(iOS7):https://stackoverflow.com/a/4457772/2410800
我也有同样的问题。等待回应。 – python