---
title: UICollectionViewController
framework: uikit
role: symbol
role_heading: Class
path: uikit/uicollectionviewcontroller
---

# UICollectionViewController

A view controller that specializes in managing a collection view.

## Declaration

```swift
@MainActor class UICollectionViewController
```

## Mentioned in

Displaying and managing views with a view controller

## Overview

Overview A view controller implements the following behavior: If the collection view controller has an assigned nib file or was loaded from a storyboard, it loads its view from the corresponding nib file or storyboard. If you create the collection view controller programmatically, it automatically creates a new unconfigured collection view object, which you can access using the collectionView property. When loading a collection view from a storyboard or nib file, the data source and delegate objects for the collection view are obtained from the nib file. If a data source or delegate is not specified, the collection view controller assigns itself to the unspecified role. When the collection view is about to appear for the first time, the collection view controller reloads the collection view data. It also clears the current selection every time the view is displayed. You can change this behavior by setting the value of the clearsSelectionOnViewWillAppear property to false. You create a custom subclass of UICollectionViewController for each collection view that you want to manage. When you initialize the controller, using the init(collectionViewLayout:) method, you specify the layout the collection view should have. Because the initially created collection view is without dimensions or content, the collection view’s data source and delegate—typically the collection view controller itself—must provide this information. You may override the loadView() method or any other superclass method, but if you do, be sure to call super in the implementation of your method. If you do not, the collection view controller may not be able to perform all of the tasks needed to maintain the integrity of the collection view.

## Topics

### Creating a collection view controller

- [init(collectionViewLayout:)](uikit/uicollectionviewcontroller/init(collectionviewlayout:).md)
- [init(nibName:bundle:)](uikit/uicollectionviewcontroller/init(nibname:bundle:).md)
- [init(coder:)](uikit/uicollectionviewcontroller/init(coder:).md)

### Getting the collection view

- [collectionView](uikit/uicollectionviewcontroller/collectionview.md)
- [collectionViewLayout](uikit/uicollectionviewcontroller/collectionviewlayout.md)

### Configuring the collection view behavior

- [clearsSelectionOnViewWillAppear](uikit/uicollectionviewcontroller/clearsselectiononviewwillappear.md)
- [installsStandardGestureForInteractiveMovement](uikit/uicollectionviewcontroller/installsstandardgestureforinteractivemovement.md)

### Integrating with a navigation controller

- [useLayoutToLayoutNavigationTransitions](uikit/uicollectionviewcontroller/uselayouttolayoutnavigationtransitions.md)

## Relationships

### Inherits From

- [UIViewController](uikit/uiviewcontroller.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSExtensionRequestHandling](foundation/nsextensionrequesthandling.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [NSTouchBarProvider](appkit/nstouchbarprovider.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)
- [UIActivityItemsConfigurationProviding](uikit/uiactivityitemsconfigurationproviding.md)
- [UIAppearanceContainer](uikit/uiappearancecontainer.md)
- [UICollectionViewDataSource](uikit/uicollectionviewdatasource.md)
- [UICollectionViewDelegate](uikit/uicollectionviewdelegate.md)
- [UIContentContainer](uikit/uicontentcontainer.md)
- [UIFocusEnvironment](uikit/uifocusenvironment.md)
- [UIPasteConfigurationSupporting](uikit/uipasteconfigurationsupporting.md)
- [UIResponderStandardEditActions](uikit/uiresponderstandardeditactions.md)
- [UIScrollViewDelegate](uikit/uiscrollviewdelegate.md)
- [UIStateRestoring](uikit/uistaterestoring.md)
- [UITraitChangeObservable](uikit/uitraitchangeobservable-67e94.md)
- [UITraitEnvironment](uikit/uitraitenvironment.md)
- [UIUserActivityRestoring](uikit/uiuseractivityrestoring.md)

## See Also

### Content view controllers

- [Displaying and managing views with a view controller](uikit/displaying-and-managing-views-with-a-view-controller.md)
- [Showing and hiding view controllers](uikit/showing-and-hiding-view-controllers.md)
- [UIViewController](uikit/uiviewcontroller.md)
- [UITableViewController](uikit/uitableviewcontroller.md)
- [UIContentContainer](uikit/uicontentcontainer.md)
