做目前这个项目的时候,在自定义tableView里重写了touchesBegan、touchesMoved、touchesEnded几种方法,后来发现这样点击cell的时候,没有任何响应,搜索了很多都没法解决,后来才白痴的发现,因为在重写touch方法的时候,没有调用其super方法,导致响应链断裂了。。。所以才点击cell无效。
后来改成如下就好了:
-(void)touchesBegan:(NSSet<UITouch*> *)touches withEvent:(UIEvent *)event{
[supertouchesBegan:toucheswithEvent:event];
/**
........
*/
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
[supertouchesMoved:toucheswithEvent:event];
/**
........
*/
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
[supertouchesEnded:toucheswithEvent:event];
/**
........
*/
}
本文详细介绍了在自定义tableView时重写touchesBegan、touchesMoved、touchesEnded方法后,出现点击cell无效的问题。通过在方法内调用super方法解决了响应链断裂的问题,并提供了正确的实现代码示例。
2089

被折叠的 条评论
为什么被折叠?



