简体   繁体   English

iOS 11的UITableView滚动故障(由reloadData表和mopub放置程序引起的内容偏移量跳跃)

[英]UITableView scroll glitch for iOS 11 (content offset jump caused by reloadData table and mopub placer)

When I upgrade to iOS 11, the tableview of my app suddenly cannot scroll smoothly. 当我升级到iOS 11时,我的应用程序的表视图突然无法平滑滚动。 Whenever I scroll (or reloadData ), the tableview will suddenly jump to a random content offset position. 每当我滚动(或reloadData )时,tableview都会突然跳到随机内容偏移位置。

I use mopub's placer to insert ads into tableview and I notice whenever the app performs [tableview reloadData] , the tableview scroll offset will go wrong and jump to a random position. 我使用mopub的布局器将广告插入到tableview中,并且我注意到,只要应用执行[tableview reloadData] ,tableview滚动偏移就会出错并跳至随机位置。

After one month after upgrade to iOS 11, I find this discussion: UITableView reload methods show behavior regression in Apple Developer Forums. 升级到iOS 11后一个月,我发现了以下讨论: UITableView重载方法在Apple Developer Forums中显示了行为回归

It turns out that this weird behavior is caused by [tableview reloadData] , and mopub ad placer always calls [tableview reloadData] . 原来,这种怪异的行为是由[tableview reloadData]引起的,并且mopub ad placer始终调用[tableview reloadData] Therefore the tableview with mopub ad placer will suffer this problem most. 因此,使用mopub ad placer的tableview最会遇到此问题。

To solve the problem, just set: 要解决该问题,只需设置:

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

and all scroll and reloadData behavior will be really smooth like iOS 10. 像iOS 10一样,所有滚动和reloadData行为都将非常流畅。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM