The nearest ancestor in the view controller hierarchy that is a navigation controller. (read-only)
@property(nonatomic, readonly, retain) UINavigationController *navigationController
Discussion
If the receiver or one of its ancestors is a child of a navigation controller, this property contains the owning navigation controller. This property is nil if the view controller is not embedded inside a navigation controller.
Availability
- Available in iOS 2.0 and later.
See Also
- @property splitViewController
- @property tabBarController
Related Sample Code
Declared In
UINavigationController.h
navigationItem
The navigation item used to represent the view controller in a parent’s navigation bar. (read-only)
@property(nonatomic, readonly, retain) UINavigationItem *navigationItem
Discussion
This is a unique instance of UINavigationItem created to represent the view controller when it is pushed onto a navigation controller. The first time the property is accessed, the UINavigationItem object is created. Therefore, you shouldn’t access this property if you are not using a navigation controller to display the view controller. To ensure the navigation item is configured, you can either override this property and add code to create the bar button items when first accessed or create the items in your view controller’s initialization code.
Avoid tying the creation of bar button items in your navigation item to the creation of your view controller’s view. The navigation item of a view controller may be retrieved independently of the view controller’s view. For example, when pushing two view controllers onto a navigation stack, the topmost view controller becomes visible, but the other view controller’s navigation item may be retrieved in order to present its back button.
The default behavior is to create a navigation item that displays the view controller’s title.
Availability
- Available in iOS 2.0 and later.
Related Sample Code
Declared In
UINavigationController.h
nibBundle
Return the name of the receiver’s nib bundle if it exists. (read-only)
@property(nonatomic, readonly, retain) NSBundle *nibBundle
Availability
- Available in iOS 2.0 and later.
See Also
- – initWithNibName:bundle:
- @property nibName
Declared In
UIViewController.h
nibName
Return the name of the receiver’s nib file, if one was specified. (read-only)
@property(nonatomic, readonly, copy) NSString *nibName
Discussion
This property contains the value specified at initialization time to the initWithNibName:bundle: method. The value of this property may be nil.
If you use a nib file to store your view controller’s view, it is recommended that you specify that nib file explicitly when initializing your view controller. However, if you do not specify a nib name, and do not override the loadView method in your custom subclass, the view controller searches for a nib file using other means. Specifically, it looks for a nib file with an appropriate name (without the .nib extension) and loads that nib file whenever its view is requested. Specifically, it looks (in order) for a nib file with one of the following names:
- If the view controller class name ends with the word “Controller”, as in MyViewController, it looks for a nib file whose name matches the class name without the word “Controller”, as in MyView.nib.
- It looks for a nib file whose name matches the name of the view controller class. For example, if the class name is MyViewController, it looks for a MyViewController.nib file.
Availability
- Available in iOS 2.0 and later.
See Also
- – initWithNibName:bundle:
- @property nibBundle
Declared In
UIViewController.h