使用 UIScrollView 自定义 UITableViewCell [英] Custom UITableViewCell with UIScrollView

查看:38
本文介绍了使用 UIScrollView 自定义 UITableViewCell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当 UITableViewCell 中有 UIScrollView 时,Cell 不接收触摸事件.有没有办法取消 UIScrollView 的点击事件(只需要处理滚动)?

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)?

推荐答案

如果你需要触摸通过,实现一个 UIScrollView 的子类,并添加这些:

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.

这篇关于使用 UIScrollView 自定义 UITableViewCell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆