TableViewCell中添加ScrollView点击事件的问题

在Cell中添加ScrollView时,Cell的点击事件被ScrollView截取了。可以设置ScrollView的userInteractionEnabled属性值为NO,但是这样ScrollView的滑动手势也失效了,没有达到我想要的效果。

我的解决办法是写一个ScrollView的子类,并重写ScrollView处理点击事件的方法

@interface CellScroll : UIScrollView
@property (nonatomic, retain) HomeCell *cell;
@end

@implementation CellScroll
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    [_cell touchesBegan:touches withEvent:event];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    [_cell touchesEnded:touches withEvent:event];
}
@end

这样就实现了点击事件的手动传递

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容