且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

表格视图重新加载节崩溃

更新时间:2023-02-02 13:11:44

在包含 UISwitch UITableViewCell 中,我遇到了同样的问题.我通过在重新加载各节之前调用 [self.tableview reloadData] 解决了该问题:

I had the same issue in UITableViewCell comprising UISwitch. I solved the problem by calling [self.tableview reloadData] before reloading the sections:

NSIndexSet *sections = [[NSIndexSet alloc] initWithIndex:2];
[self.tableView reloadData];
[self.tableView reloadSections:sections withRowAnimation:UITableViewRowAnimationFade];

如果您致电,也会发生相同的问题

The same problem happens if you call:

[self.tableView reloadRowsAtIndexPaths:[self.tableView indexPathsForVisibleRows] withRowAnimation:UITableViewRowAnimationFade]

无需先重新加载数据.