Instance Method

moveSection(_:toSection:)

Moves a section from one location to another in the collection view.

Declaration

func moveSection(_ section: Int, toSection newSection: Int)

Parameters

section

The index path of the section you want to move. This parameter must not be nil.

newSection

The index path of the section’s new location. This parameter must not be nil.

Discussion

Use this method to reorganize existing sections and their contained items. You might do this when you rearrange sections within your data source object or in response to user interactions with the collection view. The collection view updates the layout as needed to account for the move, animating new views into position as needed.

You can also call this method from a block passed to the performBatchUpdates(_:completion:) method when you want to animate multiple separate changes into place at the same time. See the description of that method for more information.

See Also

Inserting, Moving, and Deleting Sections

func insertSections(IndexSet)

Inserts new sections at the specified indexes.

func deleteSections(IndexSet)

Deletes the sections at the specified indexes.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software