iOS
TableView
TableViewCell setAccessoryView
cell setAccessoryView
cell.accessoryView = xxx
iOS 14 使用 cell setAccessoryView API不会出现问题
[cell setAccessoryView:self.colorButton];
iOS 15 上发现,当刷新tableView的时候,内存暴涨,然后应用程序卡死
检查了原因是 cell setAccessoryView:self.colorButton] 导致的。
好像没有什么好的解决方案,这貌似是iOS 15上的一个bug。
解决方案:
/// It is normal to use setAccessoryView before iOS 15.
/// After iOS 15, there will be no problem in the first loading of tableView, and the memory will skyrocket after the second refresh, causing the application to freeze.
//[cell setAccessoryView:self.colorButton];
[self.colorButton setFrame:CGRectMake(CGRectGetWidth(cell.frame) - 36 - 16, CGRectGetHeight(cell.frame)*0.5 - 18, 36, 36)];
[cell.contentView addSubview:self.colorButton];
不使用setAccessoryView 这个API 了,直接添加到cell 的contentView上不会出现问题。