UICollectionViewController Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/UIKit.framework
Availability
Available in iOS 6.0 and later.
Declared in
UICollectionViewController.h
Related sample code

Overview

The UICollectionViewController class represents a view controller whose content consists of a collection view. It implements the following behavior:

You create a custom subclass of UICollectionViewController for each collection view that you want to manage. When you initialize the controller, using the initWithCollectionViewLayout: 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.

Tasks

Initializing the UICollectionViewController Object

Getting the Collection View

Configuring the Collection View Behavior

Properties

clearsSelectionOnViewWillAppear

A Boolean value indicating if the controller clears the selection when the collection view appears.

@property (nonatomic) BOOL clearsSelectionOnViewWillAppear
Discussion

The default value of this property is YES. When YES, the collection view controller clears the collection view’s current selection when it receives a viewWillAppear: message. Setting this property to NO preserves the selection.

Availability
  • Available in iOS 6.0 and later.
Declared In
UICollectionViewController.h

collectionView

The collection view object managed by this view controller.

@property (nonatomic, retain) UICollectionView *collectionView
Discussion

If you assign a new collection view object to this property and that view’s data source or delegate are not yet set, the collection view controller makes itself the delegate or data source or both.

Availability
  • Available in iOS 6.0 and later.
Related Sample Code
Declared In
UICollectionViewController.h

Instance Methods

initWithCollectionViewLayout:

Initializes a collection view controller and configures the collection view with the provided layout.

- (id)initWithCollectionViewLayout:(UICollectionViewLayout *)layout
Parameters
layout

The layout object to associate with the collection view. The layout controls how the collection view presents its cells and supplementary views.

Return Value

An initialized UICollectionViewController object or nil if the object could not be created.

Availability
  • Available in iOS 6.0 and later.
Declared In
UICollectionViewController.h

Did this document help you? Yes It's good, but... Not helpful...