I have a UITableView that has two modes. When we switch between the modes I have a different number of sections and cells per section. Ideally, it would do some cool anima
Native UITableView animations in Swift
Insert and delete rows all at once with tableView.performBatchUpdates so they occur simultaneously. Building on the answer from @iKenndac use methods such as:
tableView.insertSectionstableView.insertRowstableView.deleteSectionstableView.deleteRowsEx:
tableView.performBatchUpdates({
tableView.insertSections([0], with: .top)
})
This inserts a section at the zero position with an animation that loads from the top. This will re-run the cellForRowAt method and check for a new cell at that position. You could reload the entire table view this way with specific animations.
Re: the OP question, a conditional flag would have been needed to show the cells for the alternate table view state.