moveSection(_:toSection:)
Moves a section to a new location in the table view.
Declaration
func moveSection(_ section: Int, toSection newSection: Int)Parameters
- section:
The index of the section to move.
- newSection:
The index in the table view that’s the destination of the move for the section. The existing section at that location slides up or down to an adjoining index position to make room for it.
Discussion
You can combine section-move operations with section-insertion and section-deletion operations within a beginUpdates()–endUpdates() block to have all changes occur together as a single animation.
Unlike the section-insertion section row-deletion methods, this method doesn’t take an animation parameter. For sections that are moved, the moved section animates straight from the starting position to the ending position. Also unlike the other methods, this method allows only one section to be moved per call. If you want multiple section moved, call this method repeatedly within a beginUpdates()–endUpdates() block.