UINavigationController
The reference links are well written and the reference links are clearly listed
UINavigationController inherits the VC of UIViewController which belongs to the container class and manages the VC according to stack management principles
There are several parts
- Navigation toolbar
- Custom content
- Navigation bar
- Navigation view
The Item of
Nav title, button return button right button these things are modified by self.navItem for every VC that’s pushed into nav
The bar section
There’s only one, and it belongs to UINavigationController, which is common to all UIView Controllers. So, when you change the background image or color of the UINavigationBar, you’re changing the background image or color of the NavigationBar of all UIViewControllers.
UINavigationController, UINavigationBar, UINavigationBarItem associations and differences
UINavigationCOntroller is a subclass of ViewCOntroller, and it has a property called ViewControllers, which is a container class that holds many VCs, and manages those VCs through UINavigationBar, which is a subclass of UIview, However, a container has only one Bar, which is mainly responsible for the color background image of the navigation Bar. Each VC managed corresponds to a UINaviagtionBarItem, through which the title and button on the Bar can be controlled and changed
So UINavigationController is made up of UINavigationBar, UINavigationBar is divided into two parts the first part is unique to UINavigationController and shared with each VC, The second part is UINavigationBarItem. Each MANAGED VC has an Item, through which VC controls the title button displayed on the Bar and other information.
other
The height of UINavigationBar is 44
A single line of text that displays at the top of the navigation bar.
wantsFullScreenLayout
A property of the viewController. This property defaults to NO if set to YES. If the Statusbar, NavigationBar, toolbar is translucent, viewController views will zoom below them, But note that tabBar is out of scope, that is, whether the property is YES or not, the view does not overwrite the tabBar.
The navigationBar refresh
NavigationBar contains several important components: leftBarButtonItem, rightBarButtonItem, backBarButtonItem and title. When a View Controller is added to navigationController, the navigationBar display follows the following principles:
1) Left side of the navigationBar
A) If the current viewController has leftBarButtonItem set, the leftBarButtonItem of the current VC is displayed.
B) If the current viewController is not set to leftBarButtonItem and the current VC is not rootVC, the backBarButtonItem of the previous VC layer will be displayed. If the previous layer VC does not specify backBarButtonItem, the system will automatically generate a back button based on the previous layer VC’s title attribute and display it.
C) If the current viewController is not set to leftBarButtonItem and the current VC is rootVC, nothing will be displayed on the left.
Note here: 5.0 the new one attribute leftItemsSupplementBackButton, by specifying this property to YES, allows leftBarButtonItem and backBarButtonItem shows at the same time, The leftBarButtonItem is displayed to the right of the backBarButtonItem.
2) Title
A) if the current VC through. NavigationItem. TitleView titleView specifies the custom, the system will display the specified titleView, attention should be paid to the custom here titleView height not more than the height of the navigationBar, Otherwise the bounds are displayed.
Navigationitem. title if the title of the current VC is specified, the UILabel will be displayed according to the title of the current VC or the contents of the current VC navigationItem.title. The content of NavigationItem. title is displayed preferentially.
3) The Right side of the navigationBar
A) displays the rightBarButtonItem if the current VC specifies it.
B) display nothing if the current VC does not specify the rightBarButtonItem.
delegate
// Called when the navigation controller shows a new top view controller via a push, pop or setting of the view controller stack. - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated; - (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated;Copy the code
ViewControllers of UINavigationController
Through this property we can realize one-time replaces the whole navigationController level, through this process if setViewControllers: animated: to set up, and specify the animation to YES, The animation jumps from the VC shown in the current navigationController to the top VC of the target viewController, while other vC’s in the middle are removed and added directly from the VC hierarchy (without animation).
topViewController Vs visibleViewController
The topViewController represents the top VC in the current navigation stack, and the visibleViewController represents the currently visible VC, which could be the topViewController, It could be the VC presented by the current topViewController. So the two properties of UINavigationController are usually the same, but they might be different.