美文网首页
UITableViewCel l中UIButton点击没反应

UITableViewCel l中UIButton点击没反应

作者: xu1Peng | 来源:发表于2021-04-21 11:44 被阅读0次

最近,接收一个老项目,在iPhone7上UIButton点击没问题,但是在iPhone12上运行UIButton点击没反应。查看原因之后发现点击UIButton进入cell的didSelectRowAtIndexPath 方法中。

原因:

因为最新的iOS的SDK不再遍历cell 的subview去分发事件,而是遍历cell.contentView的subView去分发事件了。所以这样的话,就明了了解决方案。

解决方法:

使用如下方法添加子视图: [cell.contentView addSubview:self.morebtn];

相关文章

网友评论

      本文标题:UITableViewCel l中UIButton点击没反应

      本文链接:https://www.haomeiwen.com/subject/mzwalltx.html