使用UIScrollView自定义UITableViewCell

时间:2011-01-31 13:23:23

标签: iphone uitableview uiscrollview scroll

当UITableViewCell中有UIScrollView时,

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

2 个答案:

答案 0 :(得分:5)

如果需要接触,请实现UIScrollView的子类,并添加以下内容:

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

单元格只接受点击,所以它会起作用。

答案 1 :(得分:0)

这太棒了!我正在拉这个头发。