MKAnnotationViewDragStateEnding从未发送过

时间:2014-08-04 16:43:21

标签: ios7 mapkit mkannotationview

我试图从轨道(坐标列表)中拖动MKAnnotation

性能不是以前对iOS6经验的预期,现在当Annotation向上移动向下移动直到你按下了Point ...肯定我做错了什么:S

无论如何,我不希望MKAnnotationViewDragStateEnding更新音轨的MKPolygon,但状态永远不会到来。

我有自己的MKAnnotation课程遵循Apple指南

@interface SMAnnotation : NSObject <MKAnnotation>
{ 
   CLLocationCoordinate2D coordinate;    
} 
@property (nonatomic,readonly) CLLocationCoordinate2D   coordinate;

- (id)initWithCoordinate:(CLLocationCoordinate2D)coord;
- (void)setCoordinate:(CLLocationCoordinate2D)newCoordinate;

我已经在MKMapView的UIViewController上定义了draggable

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
    MKPinAnnotationView *pin = [[MKPinAnnotationView alloc] initWithAnnotation: annotation reuseIdentifier: @"myPin"];
    pin.animatesDrop = YES;
    pin.draggable = YES;
    pin.enabled = YES;
    pin.pinColor = MKPinAnnotationColorGreen;

    return pin;
}

(我在此处阅读了一些以前的解决方案后删除了重用代码但没有成功)

我包括评估控制器性能的方法:

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)annotationView
didChangeDragState:(MKAnnotationViewDragState)newState fromOldState:(MKAnnotationViewDragState)oldState
{
    switch (newState) {
        case MKAnnotationViewDragStateNone:
...

日志的样本是下一个:

2014-08-04 18:08:24.030 XXX[8462:60b] Received an Starting State
2014-08-04 18:08:24.031 XXX[8462:60b] starting At at 41.778202,3.029813
2014-08-04 18:08:24.031 XXX[8462:60b] Received an Dragging State 
2014-08-04 18:08:24.565 XXX[8462:60b] Received an None State
2014-08-04 18:08:28.333 XXX[8462:60b] Received an Starting State
2014-08-04 18:08:28.334 XXX[8462:60b] starting At at 41.778204,3.030127
2014-08-04 18:08:28.334 XXX[8462:60b] Received an Dragging State
2014-08-04 18:08:28.866 XXX[8462:60b] Received an None State
2014-08-04 18:08:39.920 XXX[8462:60b] Received an Starting State
2014-08-04 18:08:39.920 XXX[8462:60b] starting At at 41.778165,3.030228
2014-08-04 18:08:39.920 XXX[8462:60b] Received an Dragging State
2014-08-04 18:08:40.454 XXX[8462:60b] Received an None State

之后我还创建了一个Customized MKAnnotationView:MKPinAnnotationView

- (void)setDragState:(MKAnnotationViewDragState)newDragState animated:(BOOL)animated
{
    [super setDragState:newDragState animated:animated];

    switch (newDragState) {
        case MKAnnotationViewDragStateNone:
        {
            NSLog(@"AV::Received an None State");
            break;
        }
...
    }
}

MKAnnotationViewDragStateEnding在MKAnnotationView上接收但未传播到MKMapViewDelegate ...

有什么建议吗?

感谢!!!

1 个答案:

答案 0 :(得分:0)

在评估了一些变通方法之后,我决定创建一个MKMapView子类来保证MKAnnotations的顺序。

MKMapView默认提供NSSet,但对于轨道,顺序是相关的。

使用此解决方法我不需要拖动报告获取新坐标并重绘MKPolyline,我可以使用MKMapView子类上的NSArray来执行此操作。

此致