UITableView reload methods show behavior regression

It seems I'm the first one to report this but I see very different behavior on UITableView.reloadData/reloadSections on iOS 11.


When calling reloadData, the UITableView systematically scrolls back up and looses contentOffset. When calling reloadSections (with any animation effect), the scrolling is also messed up but it doesn't necesseraly go back to beginning.


Am I the only one seeing this behavior ? Is this a know issue ?

Accepted Reply

Hi devmob,

I have the same issue. I try this code fixed my issue, you can try.



self.tableView.estimatedRowHeight = 0;

self.tableView.estimatedSectionHeaderHeight = 0;

self.tableView.estimatedSectionFooterHeight = 0;

Replies

You are not the only one. We are having the same issue when trying to expand/collapsing our cells.


Previously, collapsing a cell and having a UITableView contentsize inferior to the container would cause a smoth scrolling reloading with the .automatic parameter.

We tried the new performBatchUpdates method, does not work either.


Also, when scrolling while expanding (on a reloadSections), we have a weird teleport to the top of the UITableView when the scrolling occurs, only if the contentSize of the tableview is superior to the container after the scrolling has occured (the cell expansion can cause this condition). Have spent a few hours already with my team on that. We thought at first the issue was related to the queue we were dispatching the operation...


Please keep us posted if you have any solution to that problem, we would like to patch this before iOS 11 release 😟

Play around with the UITableViewRowAnimation, or try setting table view type groupped table view or before the call to either reload method, switch off & on animations -


UIView.setAnimationsEnabled(false)

--- reload table here

UIView.setAnimationsEnabled(true)

Our TableView was already a grouped TableView (so we can have headers inside it). Tweaking with the UITableViewRowAnimation did not change a thing.

Disabling the UIView animation before the reload section / or data did not change a thing either.

We also tried disabling the auto content insets adjusting introduced with iOS 11 (and playing with it), and the delay content touches.

Hi devmob,

I also have the same issue. Did you find any way to resolve it?

And did you report this issue to Apple?


Thanks!

Hi devmob,

I have the same issue. I try this code fixed my issue, you can try.



self.tableView.estimatedRowHeight = 0;

self.tableView.estimatedSectionHeaderHeight = 0;

self.tableView.estimatedSectionFooterHeight = 0;

@rshinich This worked for me as well luckily, I'd still call this an Apple bug though.

ping on this: did anyone fill a bug ?


I am seeing many weirds behvaior around autolayout when the table view is grouped and contains many cells, in particular when clicking on a row the location of the click gets misplaced and another row is selected. This only happens on ios11, and (AFAICT) only on iPad, under certain circomstances I do not fully understand. Disabling auto-layout completely (as mentionned below) works but then you lose all the benefits of autolayout.

It's a good idear for my question,thank you!

It works. Confirmed.

Thank you!!!!!!!!

Thanks for sharing your solution rshinich, it worked for me as well.

Thank you my friend, this also helped with my issue!

Thanks, this helped me too. Has this bug been reported? I couldn't create an example project to reproduce the issue.