Custom UITableViewCell with UIScrollView

纵饮孤独 提交于 2020-01-06 07:08:17

问题


Cell doesn't receive touch events, when there is UIScrollView inside UITableViewCell. Is there any way to cancel tap events for UIScrollView (needs only to handle scrolling)?


回答1:


If you need touches to go through, implement a subclass of UIScrollView, and add these:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{    
    // Pass to parent
    [super touchesBegan:touches withEvent:event];
    [self.nextResponder touchesBegan:touches withEvent:event];
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    // Pass to parent
    [super touchesEnded:touches withEvent:event];
    [self.nextResponder touchesEnded:touches withEvent:event];
}

The cell only interecepts taps, so it'll work.




回答2:


This is brilliant! I was pulling my hair on this one.



来源:https://stackoverflow.com/questions/4851323/custom-uitableviewcell-with-uiscrollview

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