View Controllers

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


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.



Managing Content in Your App's Windows

Build your app’s user interface from view controllers, and change the currently visible view controller when you want to display new content.

Content View Controllers

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

Displaying and Managing Views with a View Controller

Build a view controller in storyboards, configure it with custom views, and fill those views with your app’s data.

Showing and Hiding View Controllers

Display view controllers using different techniques, and pass data between them during transitions.


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


A view controller that specializes in managing a table view.


A view controller that specializes in managing a collection view.


A set of methods for adapting the contents of your view controllers to size and trait changes.

Container View Controllers

Creating a Custom Container View Controller

Create a composite interface by combining content from one or more view controllers with other custom views.


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


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


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


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


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


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


An item in a tab bar.


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

Presentation Management

Disabling Pulling Down a Sheet

Disable the sheet pull-down gesture when dismissal would be destructive.


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

Search Interface


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


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


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


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.

Using Suggested Searches with a Search Controller

Create a search interface with a table view of suggested searches.

Images and Video


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


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

Documents and Directories

Adding a Document Browser to Your App

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

Providing Access to Directories

Use a document picker to access the content of a directory outside your app’s container.

Building a Document Browser-Based App

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

Building a Document Browser App for Custom File Formats

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


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


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


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

iCloud Sharing


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

Activities Interface


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


A proxy for data passed to an activity view controller.


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


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

Font Picker


A view controller that manages the interface for selecting a font provided by the system or installed by the user.


A set of optional methods for receiving messages about the user’s interaction with the font picker.


The filters and display settings a font picker view controller uses to set up a font picker.

Word Lookup


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

Printer Picker


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

Interface Orientation


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


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

Interface Restoration

Restoring Your App’s State

Preserve and restore information related to the user’s current activities.

Preserving Your App's UI Across Launches

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


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


The interface that restoration classes use to restore preserved objects.


Methods for adding objects to your state restoration archives.

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.

Appearance Customization

Add Dark Mode support to your app, customize the appearance of bars, and use appearance proxies to modify your UI.

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.