View Controllers

Manage your interface using view controllers and facilitate navigation around your app's content.

Overview

You use view controllers to manage your UIKit app’s interface. A view controller manages a single root view, which may itself contain any number of subviews. User interactions with that view hierarchy are handled by your view controller, which coordinates with other objects of your app as needed. Every app has at least one view controller whose content fills the main window. If your app has more content than can fit onscreen at once, use multiple view controllers to manage different parts of that content.

A container view controller embeds the content of other view controllers into its own root view. A container view controller may mix custom views with the contents of its child view controllers to facilitate navigation or to create unique interfaces. For example, a UINavigationController object manages a navigation bar and a stack of child view controllers (only one of which is visible at a time), and provides an API to add and remove child view controllers from the stack.

UIKit provides several standard view controllers for navigation and managing specific types of content. You define the view controllers containing your app’s custom content. You may also define custom container view controllers to implement new navigation schemes.

Topics

Custom View Controllers

Subclass a view controller to manage your app's custom interface.

UIViewController

An object that manages a view hierarchy for your UIKit app.

UITableViewController

A view controller that specializes in managing a table view.

UICollectionViewController

A view controller that specializes in managing a collection view.

UIContentContainer

Methods for adapting the contents of your view controllers to size and trait changes.

Split View Interface

UISplitViewController

A container view controller that implements a master-detail interface.

Navigation Interface

UINavigationController

A container view controller that defines a stack-based scheme for navigating hierarchical content.

UINavigationBar

Navigational controls displayed in a bar along the top of the screen, usually in conjunction with a navigation controller.

UINavigationItem

The items to be displayed by a navigation bar when the associated view controller is visible.

Page View Interface

UIPageViewController

A container view controller that manages navigation between pages of content, where each page is managed by a child view controller.

Tab View Interface

UITabBarController

A container view controller that manages a radio-style selection interface, where the selection determines which child view controller to display.

UITabBar

A control that displays one or more buttons in a tab bar for selecting between different subtasks, views, or modes in an app.

UITabBarItem

An item in a tab bar.

Search Interface

UISearchContainerViewController

A view controller that manages the presentation of search results in your interface.

UISearchController

A view controller that manages the display of search results based on interactions with a search bar.

UISearchBar

A specialized view for receiving search-related information from the user.

UISearchResultsUpdating

A set of methods that let you update search results based on information the user enters into the search bar.

Displaying Searchable Content by Using a Search Controller

Create a user interface with searchable content in a table view.

Images and Video

UIImagePickerController

A view controller that manages the system interfaces for taking pictures, recording movies, and choosing items from the user's media library.

UIVideoEditorController

A view controller that manages the system interface for trimming video frames and encoding a previously recorded movie.

Document Browser

Adding a Document Browser to Your App

Give users access to their local or remote documents from within your app.

Building a Document Browser-Based App

Use a document browser to provide access to the user’s text files.

UIDocumentBrowserViewController

A view controller for browsing and performing actions on documents stored locally and in the cloud.

UIDocumentPickerViewController

A view controller that provides access to documents or destinations outside your app’s sandbox.

Building an App Based on the Document Browser View Controller

Implement a custom document file format to manage user interactions with files on different cloud storage providers.

Document Previewing

UIDocumentInteractionController

A view controller that previews, opens, or prints files whose file format cannot be handled directly by your app.

iCloud Sharing

UICloudSharingController

A view controller that presents standard screens for adding and removing people from a CloudKit share record.

Activities Interface

UIActivityViewController

A view controller that you use to offer standard services from your app.

UIActivityItemProvider

A proxy for data passed to an activity view controller.

UIActivityItemSource

A set of methods used by an activity view controller to retrieve the data items to act on.

UIActivity

An abstract class that you subclass to implement app-specific services.

Word Lookup

UIReferenceLibraryViewController

A view controller that displays a standard interface for looking up the definition of a word or term.

Printer Picker

UIPrinterPickerController

A view controller that displays the standard interface for selecting a printer.

Presentation Controllers

UIPresentationController

An object that manages the transition animations and the presentation of view controllers onscreen.

Interface Restoration

Preserving Your App's UI Across Launches

Return your app to its previous state after it is terminated by the system.

UIViewControllerRestoration

The methods that objects adopt so that they can act as a "restoration class” for view controllers during state restoration.

UIObjectRestoration

The interface that restoration classes use to restore preserved objects.

UIStateRestoring

Methods for adding objects to your state restoration archives.

Interface Orientation

UIInterfaceOrientationIsPortrait

Returns a Boolean value indicating whether the user interface is currently presented in a portrait orientation.

UIInterfaceOrientationIsLandscape

Returns a Boolean value indicating whether the user interface is currently presented in a landscape orientation.

See Also

User Interface

Views and Controls

Present your content onscreen and define the interactions allowed with that content.

View Layout

Use stack views to lay out the views of your interface automatically. Use Auto Layout when you require precise placement of your views.

Animation and Haptics

Provide feedback to users using view-based animations and haptics.

Windows and Screens

Provide a container for your view hierarchies and other content.