UINavigationBarDelegate Protocol Reference

Conforms to
Framework
/System/Library/Frameworks/UIKit.framework
Availability
Available in iOS 2.0 and later.
Companion guide
Declared in
UINavigationBar.h
Related sample code

Overview

The UINavigationBarDelegate protocol defines optional methods that a UINavigationBar delegate should implement to update its views when items are pushed and popped from the stack. The navigation bar represents only the bar at the top of the screen, not the view below. It’s the application’s responsibility to implement the behavior when the top item changes.

You can control whether an item should be pushed or popped by implementing the navigationBar:shouldPushItem: and navigationBar:shouldPopItem: methods. These methods should return YES if the action is allowed; otherwise, NO.

The screen should always reflect the top item on the navigation bar. You implement the navigationBar:didPushItem: method to update the view below the navigation bar to reflect the new item. Similarly, you implement the navigationBar:didPopItem: method to replace the view below the navigation bar.

Tasks

Pushing Items

Popping Items

Instance Methods

navigationBar:didPopItem:

Tells the delegate that an item was popped from the navigation bar.

- (void)navigationBar:(UINavigationBar *)navigationBar didPopItem:(UINavigationItem *)item
Parameters
navigationBar

The navigation bar that the item is being popped from.

item

The navigation item that is being popped.

Discussion

If animating the pop operation, this method is invoked after the animation ends; otherwise, it is invoked immediately after the pop.

Availability
  • Available in iOS 2.0 and later.
Declared In
UINavigationBar.h

navigationBar:didPushItem:

Tells the delegate that an item was pushed onto the navigation bar.

- (void)navigationBar:(UINavigationBar *)navigationBar didPushItem:(UINavigationItem *)item
Parameters
navigationBar

The navigation bar that the item is being pushed onto.

item

The navigation item that is being pushed.

Discussion

If pushing an item onto the navigation bar is animated, this method is invoked after the animation ends; otherwise, it is invoked immediately after the push.

Availability
  • Available in iOS 2.0 and later.
Declared In
UINavigationBar.h

navigationBar:shouldPopItem:

Returns a Boolean value indicating whether the navigation bar should pop an item.

- (BOOL)navigationBar:(UINavigationBar *)navigationBar shouldPopItem:(UINavigationItem *)item
Parameters
navigationBar

The navigation bar that the item is being popped from.

item

The navigation item that is being popped.

Return Value

YES if the item should be popped; otherwise, NO.

Discussion

Sent to the delegate before popping an item from the navigation bar.

Availability
  • Available in iOS 2.0 and later.
Declared In
UINavigationBar.h

navigationBar:shouldPushItem:

Returns a Boolean value indicating whether the navigation bar should push an item.

- (BOOL)navigationBar:(UINavigationBar *)navigationBar shouldPushItem:(UINavigationItem *)item
Parameters
navigationBar

The navigation bar that the item is being pushed onto.

item

The navigation item that is being pushed.

Return Value

YES if the item should be pushed; otherwise, NO.

Discussion

Sent to the delegate before pushing an item onto the navigation bar.

Availability
  • Available in iOS 2.0 and later.
Declared In
UINavigationBar.h