iOS do not forward touches to views below

左心房为你撑大大i 提交于 2019-12-25 04:09:35

问题


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:


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 ;

} 


来源:https://stackoverflow.com/questions/28558335/ios-do-not-forward-touches-to-views-below

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!