使用UIScrollView自定义UITableViewCell

mar*_*rko 0 iphone scroll uitableview uiscrollview

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

Eth*_*han 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];
}
Run Code Online (Sandbox Code Playgroud)

细胞只能接触水龙头,所以它会起作用.