我正在尝试使用以下代码检测用户何时启动并停止在mapview上拖动:
- (void)viewDidLoad {
UIPanGestureRecognizer* panRec = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(didDragMap:)];
[panRec setDelegate:self];
[_mapView addGestureRecognizer:panRec];
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
return YES;
}
- (void)didDragMap:(UIGestureRecognizer*)gestureRecognizer {
if (gestureRecognizer.state == UIGestureRecognizerStateEnded){
NSLog(@"drag ended");
}
}
然而,当UIGestureRecognizer给我我想要的东西时,地图似乎根本不移动。
可能出现什么问题?
答案 0 :(得分:0)
好吧,我只需要添加这个
panGesture.cancelsTouchesInView = NO;
不确定是否是百度地图错误,因为MKMapView在没有该选项的情况下工作正常。