Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. Whenever I scroll (or reloadData), the tableview will suddenly jump to a random content offset position.

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.

like image 218
Sean Cheng Avatar asked Nov 05 '17 15:11

Sean Cheng


1 Answers

After one month after upgrade to iOS 11, I find this discussion: UITableView reload methods show behavior regression in Apple Developer Forums.

It turns out that this weird behavior is caused by [tableview reloadData], and mopub ad placer always calls [tableview reloadData]. Therefore the tableview with mopub ad placer will suffer this problem most.

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.

like image 75
Sean Cheng Avatar answered Jan 31 '23 15:01

Sean Cheng