UITableView deleteRows glitch

Hello, I am having a tableview with multiple sections (more than 10), which can be expanded and collapsed to show about 13 rows. The expanding part works ok, but when I am near the end of the tableView and I want to collapse an expanded sections, the tableView scrolls up leaving a gap (it has a negative content offset - ex. -320), and goes to normal when you start interacting with the tableView. I couldn't figure it out why the table view has this weird behavior. The rows deletion code is done inside performBatchUpdates.


Do you have any ideas what could cause this issue?


NOTE: The behavior seems to be correct on iOS 10. Seems to be broken from iOS 11.

Replies

When you collapse / expand a section, you set some flag in dataSource I suppose.

Do you reload data after expanding / collapsing ?


Could you show the code ?

Sorry for the late reply. No, I do not reload the data, I am using DifferenceKit library in order to compute the changes required (rows that need to be inserted/deleted). The only way I could make it work was by converting from UITableView to UICollectionView, as the latter one seems to behave as expected. The code that deals with the update on the tableview can be seen in the DifferenceKit library.

You should have told you were using a library.


Problem may be there, you should contact them.

No it's not the library, since I managed to reproduce the bug without the library. It's a bug in UIKit as the same code runs perfectly fine in iOS 10, but not on iOS 11 and 12.