UIKit.UINavigationBar Class
A UIKit.UIView that displays the standard hierarchical navigation metaphor for iOS.

See Also: UINavigationBar Members


[Foundation.Register("UINavigationBar", true)]
public class UINavigationBar : UIView, IUIBarPositioning, IDisposable

See Also



The MonoTouch API supports two styles of event notification: the Objective-C style that uses a delegate class or the C# style using event notifications.

The C# style allows the user to add or remove event handlers at runtime by assigning to the events of properties of this class. Event handlers can be anyone of a method, an anonymous methods or a lambda expression. Using the C# style events or properties will override any manual settings to the Objective-C Delegate or WeakDelegate settings.

The Objective-C style requires the user to create a new class derived from UIKit.UINavigationBarDelegate class and assign it to the UIKit.Delegate property. Alternatively, for low-level control, by creating a class derived from Foundation.NSObject which has every entry point properly decorated with an [Export] attribute. The instance of this object can then be assigned to the UINavigationBar.WeakDelegate property.


The UIKit.UINavigationBar maintains a stack of UIKit.UINavigationItems. The UIKit.UINavigationBar displays the UINavigationBar.TopItemUIKit.UINavigationItem. You can push and pop UIKit.UINavigationItems using UINavigationBar.PushNavigationItem and UINavigationBar.PopNavigationItemAnimated.

The UIKit.UINavigationBar is most commonly seen in conjunction with a UIKit.UINavigationController, which manages the UIKit.UINavigationBar and pushes and pops the necessary UIKit.UINavigationItems.

Each UIKit.UINavigationItem defines left, center, and right subviews. The left and right subviews are expected to be of type UIKit.UIBarButtonItem, while the center subview by default displays the value of the UINavigationItem.Title property. The center view can be further customized by assigning to the UINavigationItem.TitleView property.

When used with a UIKit.UINavigationController, the current UIKit.UIViewController's UIViewController.NavigationItem property is used to manipulate the UIKit.UINavigationBar, as shown in the following example.

C# Example

          public class MyViewController : UIViewController
             public override void ViewDidLoad ()
                base.ViewDidLoad ();
                this.NavigationItem.Title = "NavigationItem.Title";
                this.NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Action, OnAction);

Application developers who wish to customize the behavior of the UIKit.UINavigationController's uniquely-styled '"Back" button when using a UIKit.UINavigationController can use the following technique:

C# Example

          public class MyViewController : UIViewController
             public override void ViewWillDisappear(bool animated)
                //If `this` not in stack, we've been popped via "Back" button
                if(NavigationController.ViewControllers.Contains(this) == false)
                   Console.WriteLine("Custom behavior");

Related content


Namespace: UIKit
Assembly: Xamarin.iOS (in Xamarin.iOS.dll)
Assembly Versions: