Closed MoLice closed 3 years ago
Bug 原因分析:
理论上正确的时序应该是 tableView 先询问 - [UITableViewDataSource numberOfSectionInTableView:]
,获知列表是 0 个 section,于是就不会再询问 estimatedHeightForHeaderInSection 之类的方法。
但在 issue 描述的这种特定场景里,系统内部可能状态错乱,导致先触发了 estimatedHeightForHeaderInSection(不仅限于它,也可能是 estimatedHeightForFooterInSection、heightForRow、...),传的参数是 section = 0(UITableView 默认的 numberOfSection 为 1)但此时业务的 dataSource 数组是空的,所以访问 dataSource[0] 就出现越界的 crash。
系统在这种场景下为什么会出现这种错误的时序,原因未知,目前 QMUI 的修复方式是在 tableView 的 reloadData 第一次执行前手动检查 delegate 返回的数据和 tableView 内部的数据是否一致,如果不一致则手动刷新一次,从而规避这种问题。
Bug 表现
如何重现
可重现的 Demo: TestTableViewEstimated.zip
其他信息