适用于iOS 11的UITableView滚动故障(由reloadData表和mopub放置器引起的内容偏移跳转)

Sea*_*eng 7 iphone uitableview uiscrollview ios ios11

当我升级到iOS 11时,我的应用程序的tableview突然无法顺利滚动.每当我滚动(或reloadData)时,tableview将突然跳转到随机内容偏移位置.

我使用mopub的布局器将广告插入到tableview中,我注意到每当应用程序执行时[tableview reloadData],tableview滚动偏移都会出错并跳转到随机位置.

Sea*_*eng 39

升级到iOS 11后一个月后,我发现了这个讨论: UITableView重载方法 在Apple Developer Forums中显示行为回归.

事实证明,这种奇怪的行为是由[tableview reloadData],并且mopub ad placer总是调用[tableview reloadData].因此,使用mopub ad placer的tableview最容易遇到这个问题.

要解决这个问题,只需设置:

self.tableView.estimatedRowHeight = 0; self.tableView.estimatedSectionHeaderHeight = 0; self.tableView.estimatedSectionFooterHeight = 0;

并且所有scroll和reloadData行为都会像iOS 10一样流畅.

  • 如果我的单元格大小是动态的并且我想保持自动单元格高度怎么办? (3认同)