我有一个用户可以在地图上拖动的MKAnnotationView。
对于用户来说,拖动引脚是非常困难的。我已经尝试增加帧大小,也使用一个巨大的自定义图像。但是,似乎没有什么实际改变的点击区域的拖拽大于默认值。
因此,在发生任何事情之前,我必须尝试轻击/拖动大约十次。
MKAnnotationView *annView = [[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"bluedot"] autorelease];
UIImage *image = [UIImage imageNamed:@"blue_dot.png"];
annView.image = image;
annView.draggable = YES;
annView.selected = YES;
return annView;这里我漏掉了什么?
编辑:
原来问题是MKAnnotationView需要先被触摸,然后才能拖动它。我遇到了麻烦,因为附近有很多引脚,而我的MKAnnotationView非常小。
发布于 2012-06-06 16:06:39
我没有意识到在拖拽MKAnnotationView之前需要触摸它。
为了解决这个问题,我创建了一个定时器,它会定期选择该MKAnnotationView。
NSTimer *selectAnnotationTimer = [[NSTimer scheduledTimerWithTimeInterval:0.2 target:self selector:@selector(selectCenterAnnotation) userInfo:nil repeats:YES] retain]; 以及它调用的方法:
- (void)selectCenterAnnotation {
[mapView selectAnnotation:centerAnnotation animated:NO];
} 发布于 2014-09-02 16:47:00
您可以在鼠标按下时选择批注,而不是使用计时器。这样,您就不会弄乱注释选择,也不会为每个注释一直运行而设置计时器。
我在开发mac应用程序时遇到了同样的问题,在选择鼠标按下时的注释后,拖动效果很好。
https://stackoverflow.com/questions/10908222
复制相似问题