Class: UINavigationController
- Inherits:
-
UIViewController
- Object
- NSObject
- UIResponder
- UIViewController
- UINavigationController
Overview
The UINavigationController class implements a specialized view controller that manages the navigation of hierarchical content. This class is not intended for subclassing. Instead, you use instances of it as-is in situations where you want your application’s user interface to reflect the hierarchical nature of your content. This navigation interface makes it possible to present your data efficiently and also makes it easier for the user to navigate that content.
Direct Known Subclasses
EKEventEditViewController, GKFriendRequestComposeViewController, GKGameCenterViewController, GKMatchmakerViewController, GKTurnBasedMatchmakerViewController, MFMailComposeViewController, MFMessageComposeViewController, UIImagePickerController, UIVideoEditorController
Instance Attribute Summary (collapse)
-
- delegate
The receiver’s delegate or nil if it doesn’t have a delegate.
-
- navigationBar
readonly
The navigation bar managed by the navigation controller.
-
- navigationBarHidden
A Boolean value that determines whether the navigation bar is hidden.
-
- toolbar
readonly
The custom toolbar associated with the navigation controller.
-
- toolbarHidden
A Boolean indicating whether the navigation controller’s built-in toolbar is visible.
-
- topViewController
readonly
The view controller at the top of the navigation stack.
-
- viewControllers
The view controllers currently on the navigation stack.
-
- visibleViewController
readonly
The view controller associated with the currently visible view in the navigation interface.
Attributes inherited from UIViewController
#childViewControllers, #contentSizeForViewInPopover, #definesPresentationContext, #editing, #hidesBottomBarWhenPushed, #interfaceOrientation, #modalInPopover, #modalPresentationStyle, #modalTransitionStyle, #navigationController, #navigationItem, #nibBundle, #nibName, #parentViewController, #presentedViewController, #presentingViewController, #providesPresentationContextTransitionStyle, #restorationClass, #restorationIdentifier, #searchDisplayController, #splitViewController, #storyboard, #tabBarController, #tabBarItem, #title, #toolbarItems, #view, #wantsFullScreenLayout
Attributes inherited from UIResponder
#inputAccessoryView, #inputView, #undoManager
Instance Method Summary (collapse)
-
- initWithNavigationBarClass:toolbarClass:
Initializes and returns a newly created navigation controller that uses your custom bar subclasses.
-
- initWithRootViewController:
Initializes and returns a newly created navigation controller.
-
- popToRootViewControllerAnimated:
Pops all the view controllers on the stack except the root view controller and updates the display.
-
- popToViewController:animated:
Pops view controllers until the specified view controller is at the top of the navigation stack.
-
- popViewControllerAnimated:
Pops the top view controller from the navigation stack and updates the display.
-
- pushViewController:animated:
Pushes a view controller onto the receiver’s stack and updates the display.
-
- setNavigationBarHidden:animated:
Sets whether the navigation bar is hidden.
-
- setToolbarHidden:animated:
Changes the visibility of the navigation controller’s built-in toolbar.
-
- setViewControllers:animated:
Replaces the view controllers currently managed by the navigation controller with the specified items.
Methods inherited from UIViewController
#addChildViewController:, attemptRotationToDeviceOrientation, #beginAppearanceTransition:animated:, #canPerformUnwindSegueAction:fromViewController:withSender:, #decodeRestorableStateWithCoder:, #didMoveToParentViewController:, #didReceiveMemoryWarning, #didRotateFromInterfaceOrientation:, #disablesAutomaticKeyboardDismissal, #dismissViewControllerAnimated:completion:, #editButtonItem, #encodeRestorableStateWithCoder:, #endAppearanceTransition, #initWithNibName:bundle:, #isBeingDismissed, #isBeingPresented, #isMovingFromParentViewController, #isMovingToParentViewController, #isViewLoaded, #loadView, #performSegueWithIdentifier:sender:, #preferredInterfaceOrientationForPresentation, #prepareForSegue:sender:, #presentViewController:animated:completion:, #removeFromParentViewController, #rotatingFooterView, #rotatingHeaderView, #segueForUnwindingToViewController:fromViewController:identifier:, #setEditing:animated:, #setToolbarItems:animated:, #shouldAutomaticallyForwardAppearanceMethods, #shouldAutomaticallyForwardRotationMethods, #shouldAutorotate, #shouldPerformSegueWithIdentifier:sender:, #supportedInterfaceOrientations, #transitionFromViewController:toViewController:duration:options:animations:completion:, #updateViewConstraints, #viewControllerForUnwindSegueAction:fromViewController:withSender:, #viewDidAppear:, #viewDidDisappear:, #viewDidLayoutSubviews, #viewDidLoad, #viewWillAppear:, #viewWillDisappear:, #viewWillLayoutSubviews, #willAnimateRotationToInterfaceOrientation:duration:, #willMoveToParentViewController:, #willRotateToInterfaceOrientation:duration:
Methods inherited from UIResponder
#becomeFirstResponder, #canBecomeFirstResponder, #canPerformAction:withSender:, #canResignFirstResponder, #isFirstResponder, #motionBegan:withEvent:, #motionCancelled:withEvent:, #motionEnded:withEvent:, #nextResponder, #reloadInputViews, #remoteControlReceivedWithEvent:, #resignFirstResponder, #touchesBegan:withEvent:, #touchesCancelled:withEvent:, #touchesEnded:withEvent:, #touchesMoved:withEvent:
Methods inherited from NSObject
#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version
Constructor Details
This class inherits a constructor from NSObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class NSObject
Instance Attribute Details
- (Object) delegate
The receiver’s delegate or nil if it doesn’t have a delegate. See UINavigationControllerDelegate Protocol Reference for the methods this delegate should implement.
- (UINavigationBar) navigationBar (readonly)
The navigation bar managed by the navigation controller. (read-only) It is permissible to modify the barStyle or translucent properties of the navigation bar but you must never change its frame, bounds, or alpha values directly. To show or hide the navigation bar, you should always do so through the navigation controller by changing its navigationBarHidden property or calling the setNavigationBarHidden:animated: method.
- (Boolean) navigationBarHidden
A Boolean value that determines whether the navigation bar is hidden. If YES, the navigation bar is hidden. The default value is NO. Setting this property does not animate the hiding or showing of the navigation bar; use setNavigationBarHidden:animated: for that purpose.
- (UIToolbar) toolbar (readonly)
The custom toolbar associated with the navigation controller. (read-only) This property contains a reference to the built-in toolbar managed by the navigation controller. Access to this toolbar is provided solely for clients that want to present an action sheet from the toolbar. You should not modify the UIToolbar object directly.Management of this toolbar’s contents is done through the custom view controllers associated with this navigation controller. For each view controller on the navigation stack, you can assign a custom set of toolbar items using the setToolbarItems:animated: method of UIViewController. The visibility of this toolbar is controlled by the toolbarHidden property. The toolbar also obeys the hidesBottomBarWhenPushed property of the currently visible view controller and hides and shows itself automatically as needed.
- (Boolean) toolbarHidden
A Boolean indicating whether the navigation controller’s built-in toolbar is visible. If this property is set to YES, the toolbar is not visible. The default value of this property is YES.
- (UIViewController) topViewController (readonly)
The view controller at the top of the navigation stack. (read-only)
- (Array) viewControllers
The view controllers currently on the navigation stack. The root view controller is at index 0 in the array, the back view controller is at index n-2, and the top controller is at index n-1, where n is the number of items in the array.Assigning a new array of view controllers to this property is equivalent to calling the setViewControllers:animated: method with the animated parameter set to NO.
- (UIViewController) visibleViewController (readonly)
The view controller associated with the currently visible view in the navigation interface. (read-only) The currently visible view can belong either to the view controller at the top of the navigation stack or to a view controller that was presented modally.
Instance Method Details
- (instancetype) initWithNavigationBarClass(navigationBarClass, toolbarClass:toolbarClass)
Initializes and returns a newly created navigation controller that uses your custom bar subclasses. Use this initialization method if you want to use custom navigation bar or toolbar subclasses with the navigation controller. If you use this method, you are responsible for adding a root view controller before presenting the navigation controller onscreen.
- (Object) initWithRootViewController(rootViewController)
Initializes and returns a newly created navigation controller. This is a convenience method for initializing the receiver and pushing a root view controller onto the navigation stack. Every navigation stack must have at least one view controller to act as the root.
- (Array) popToRootViewControllerAnimated(animated)
Pops all the view controllers on the stack except the root view controller and updates the display. The root view controller becomes the top view controller. For information on how the navigation bar is updated, see “Updating the Navigation Bar.”
- (Array) popToViewController(viewController, animated:animated)
Pops view controllers until the specified view controller is at the top of the navigation stack. For information on how the navigation bar is updated, see “Updating the Navigation Bar.”
- (UIViewController) popViewControllerAnimated(animated)
Pops the top view controller from the navigation stack and updates the display. This method removes the top view controller from the stack and makes the new top of the stack the active view controller. If the view controller at the top of the stack is the root view controller, this method does nothing. In other words, you cannot pop the last item on the stack.In addition to displaying the view associated with the new view controller at the top of the stack, this method also updates the navigation bar and tool bar accordingly. In iOS 3.0 and later, the contents of the built-in navigation toolbar are updated to reflect the toolbar items of the new view controller. For information on how the navigation bar is updated, see “Updating the Navigation Bar.”
- (Object) pushViewController(viewController, animated:animated)
Pushes a view controller onto the receiver’s stack and updates the display. The object in the viewController parameter becomes the top view controller on the navigation stack. Pushing a view controller results in the display of the view it manages. How that view is displayed is determined by the animated parameter. If the animated parameter is YES, the view is animated into position; otherwise, the view is simply displayed in place. The view is automatically resized to fit between the navigation bar and toolbar (if present) before it is displayed. In addition to displaying the view associated with the new view controller at the top of the stack, this method also updates the navigation bar and tool bar accordingly. In iOS 3.0 and later, the contents of the built-in navigation toolbar are updated to reflect the toolbar items of the new view controller. For information on how the navigation bar is updated, see “Updating the Navigation Bar.”Important: In iOS 2.2 and later, if the object in the viewController parameter is already on the navigation stack, this method throws an exception. In earlier versions of iOS, the method simply does nothing.
- (Object) setNavigationBarHidden(hidden, animated:animated)
Sets whether the navigation bar is hidden. For animated transitions, the duration of the animation is specified by the value in the UINavigationControllerHideShowBarDuration constant.
- (Object) setToolbarHidden(hidden, animated:animated)
Changes the visibility of the navigation controller’s built-in toolbar. You can use this method to animate changes to the visibility of the built-in toolbar. Calling this method with the animated parameter set to NO is equivalent to setting the value of the toolbarHidden property directly. The toolbar simply appears or disappears depending on the value in the hidden parameter.
- (Object) setViewControllers(viewControllers, animated:animated)
Replaces the view controllers currently managed by the navigation controller with the specified items. You can use this method to update or replace the current view controller stack without pushing or popping each controller explicitly. In addition, this method lets you update the set of controllers without animating the changes, which might be appropriate at launch time when you want to return the navigation controller to a previous state.If animations are enabled, this method decides which type of transition to perform based on whether the last item in the items array is already in the navigation stack. If the view controller is currently in the stack, but is not the topmost item, this method uses a pop transition; if it is the topmost item, no transition is performed. If the view controller is not on the stack, this method uses a push transition. Only one transition is performed, but when that transition finishes, the entire contents of the stack are replaced with the new view controllers. For example, if controllers A, B, and C are on the stack and you set controllers D, A, and B, this method uses a pop transition and the resulting stack contains the controllers D, A, and B.