其他分享
首页 > 其他分享> > scrollview 加百度地图 手势冲突解决办法

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;
    }
    
}

标签:解决办法,scrollEnabled,tap,self,scrollview,vMap,YES,百度
来源: https://www.cnblogs.com/frounk/p/14647553.html