iOS do not forward touches to views below

2019-09-10 10:43发布

In my app I have UIScrollView which has many UITableViews. In cells of this table there is UISlider. How I can disable touch forwarding if user make scroll gesture on table view? Now if user make scroll gesture near slider (but not on it) the touch event gets forwarder to scroll view.

1条回答
小情绪 Triste *
2楼-- · 2019-09-10 11:31

You can subclass UIScrollView and add this method to the new class

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {

    UIView *result = [super hitTest:point withEvent:event] ;
    self.scrollEnabled = ![result isKindOfClass:[UISlider class]] ;
    return result ;

} 
查看更多
登录 后发表回答