****解决方法****:
-
使用UIGestureRecognizerDelegate 代理方法
-
给scrollview 添加一个手势
UIGestureRecognizer *gestur = [[UIGestureRecognizer alloc]init];
gestur.delegate=self;
[self.scrollview addGestureRecognizer:gestur];
- 给百度地图添加手势
_vMap = [[BMKMapView alloc] initWithFrame:CGRectMake(15, 0, SCREEN_WIDTH - 30, 200)];
/** 注意百度地图的缩放拖动要打开*/
_vMap.zoomEnabled = YES;
_vMap.scrollEnabled = YES;
_vMap.delegate = self;
[vContent addSubview:_vMap];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onClickBtnLoction:)];
tap.delegate = self;
vContent.userInteractionEnabled = YES;
[_vMap addGestureRecognizer:tap];
- 实现代理方法
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
//在这里判断是百度地图的view 既可以实现手势拖动 scrollview 的滚动关闭
if ([gestureRecognizer.view isKindOfClass:[BMKMapView class]] ){
self.scrollview.scrollEnabled = NO;
return YES;
}else{
self.scrollview.scrollEnabled = YES;
return NO;
}
}