Class

UINavigationItem

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

Declaration

@interface UINavigationItem : NSObject

Overview

When building a navigation interface, each view controller pushed onto the navigation stack must have a UINavigationItem object that contains the buttons and views it wants displayed in the navigation bar. The managing UINavigationController object uses the navigation items of the topmost two view controllers to populate the navigation bar with content.

A navigation item always reflects information about the view controller with which it is associated. The navigation item must provide a title to display when the view controller is topmost on the navigation stack. In addition, the item may contain additional buttons to display on the right (or trailing) side of the navigation bar. You can specify buttons and views to display on the left (or leading) side of the toolbar using the leftBarButtonItems property but the navigation controller displays those buttons only if there is space available.

The backBarButtonItem property of a navigation item reflects the back button you want displayed when the current view controller is just below the topmost view controller. In other words, the back button is not used when the current view controller is topmost.

When specifying buttons for a navigation item, you must use UIBarButtonItem objects. If you want to display custom views in the navigation bar, you must wrap those views inside a UIBarButtonItem object before adding them to the navigation item.

Topics

Initializing an Item

- initWithTitle:

Returns a navigation item initialized with the specified title.

Configuring the Title

title

The navigation item’s title displayed in the navigation bar.

largeTitleDisplayMode

The mode to use when displaying the title of the navigation bar.

UINavigationItemLargeTitleDisplayMode

Constants indicating how to size the title of this item.

Getting and Setting Properties

prompt

A single line of text displayed at the top of the navigation bar.

backBarButtonItem

The bar button item to use when a back button is needed on the navigation bar.

hidesBackButton

A Boolean value that determines whether the back button is hidden.

- setHidesBackButton:animated:

Sets whether the back button is hidden, optionally animating the transition.

leftItemsSupplementBackButton

A Boolean value indicating whether the left items are displayed in addition to the back button.

Specifying Custom Views

titleView

A custom view displayed in the center of the navigation bar when the receiver is the top item.

leftBarButtonItems

An array of custom bar button items to display on the left (or leading) side of the navigation bar when the receiver is the top navigation item.

leftBarButtonItem

A custom bar button item displayed on the left (or leading) edge of the navigation bar when the receiver is the top navigation item.

rightBarButtonItems

An array of custom bar button items to display on the right (or trailing) side of the navigation bar when the receiver is the top navigation item.

rightBarButtonItem

A custom bar button item displayed on the right (or trailing) edge of the navigation bar when the receiver is the top navigation item.

- setLeftBarButtonItems:animated:

Sets the left bar button items, optionally animating the transition to the new items.

- setLeftBarButtonItem:animated:

Sets the custom bar button item, optionally animating the transition to the new item.

- setRightBarButtonItems:animated:

Sets the right bar button items, optionally animating the transition to the new items.

- setRightBarButtonItem:animated:

Sets the custom bar button item, optionally animating the transition to the view.

Overriding the Navigation Bar's Appearance Settings

standardAppearance

The appearance settings for a standard-height navigation bar.

compactAppearance

The appearance settings for a compact-height navigation bar.

scrollEdgeAppearance

The appearance settings to use when the edge of any scrollable content reaches the matching edge of the navigation bar.

Integrating Search Into Your Interface

searchController

The search controller to integrate into your navigation interface.

hidesSearchBarWhenScrolling

A Boolean value indicating whether the integrated search bar is hidden when scrolling any underlying content.

Relationships

Inherits From

Conforms To

See Also

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.

UISplitViewController

A container view controller that implements a master-detail 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.

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.

UIPageViewController

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