ios – 为什么UITableViewCell在改变高度时闪烁?

我有一个简单的UITableView与UITableViewCells.对于表视图中的第0行,我设置了单元格的背景颜色.现在点击第0行,我只想让该行展开.为了实现这一点,我使用与描述的相同的技术来改变第0行的高度.

现在的问题是,单元格扩展和崩溃,但是每个进程在单元格上都有一个丑陋的闪烁/闪烁.我已经尝试了beginupdates / endupdates并且还使用[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationNone]重新加载该行.

什么原因造成闪光/闪光灯点击?而我该如何摆脱呢?是的,我忘了提及,我已经将单元格的选择风格设置为无.所以这不是造成这个.

解决方法

当使用单元格的不透明背景颜色时,我有同样的问题.解决方法是使用backgroundView属性,而不是backgroundColor:
UIView *backgroundView = [[UIView alloc] initWithFrame:cell.frame];
backgroundView.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.1f];
cell.backgroundView = backgroundView;
cell.backgroundColor = [UIColor clearColor];

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...