1. Uinavigationcontroller Navigation Controller
?????????????????????????????? The navigation controller can be considered as the controller of the management controller , and mainly manages the controller with hierarchical relationship.
?????? The following figure shows the flow of the navigation controller. The leftmost is the root view, which slides into the screen when the user taps the general item, and the Auto-lock view slides into the screen when the user continues to tap the Auto-lock item. Accordingly, on object management, the navigation controller uses the navigation stack. The root view controller is at the bottom of the stack, and the next stack is the general view Controller and the Auto-lock view controller. You can call the pushviewcontrolleranimated: method to push the view controller into the top of the stack, or you can call the popviewcontrolleranimated: method to eject the view controller.
2, the structure of the uinavigationcontroller composition
See, Uinavigationcontroller has Navigation bar, Navigation View, Navigation Toobar and other components.
Common Properties:
1. New project, Close arc (Automatic Reference counting), that is, to turn on manual reference counting;
2. In the AppDelegate.h file, initialize the window and add the root view-(void) dealloc{[_window release];
[Super Dealloc];
}
-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchOptions {
Self.window = [[UIWindow alloc]initwithframe:[uiscreen mainscreen].bounds];
Self.window.backgroundColor = [Uicolor whitecolor];//does not add a background color, the screen will be jammed when testing
[Self.window makekeyandvisible];
Create a View Controller object
Viewcontroller *VC = [[Viewcontroller alloc]init];
Create a Uinavigationcontroller object, which is the navigation controller
Uinavigationcontroller *nav = [[Uinavigationcontroller ALLOC]INITWITHROOTVIEWCONTROLLER:VC];
Setting the window's root view controller
_window.rootviewcontroller = nav;
[Nav release];
[VC release];
3. In the VIEWCONTROLL.M file://related properties
1) Transparent: no is opaque.
Self.navigationController.navigationBar.translucent = NO;
Main difference: Opaque in Navigation view to add a label, button, etc. with the original window (0, 128) as the origin for reference. If it is transparent, it is possible to add something that is covered out.
Such as:
is opaque, i.e. self.navigationController.navigationBar.translucent = no;
2) Set the background of the navigation bar
(a) in APPDEGLATE.M
Modify the background color of the status bar (System method)
[[UIApplication sharedapplication] setstatusbarstyle:uistatusbarstylelightcontent];
(b) in VIEWCONTROLLER.M
Self.navigationController.navigationBar.barTintColor = [Uicolor colorwithred:0.24 green:0.78 blue:0.35 alpha:1];
3) Modify the navigation background map
[Self.navigationController.navigationBar setbackgroundimage:[uiimage imagenamed:@ "[email protected]"] Forbarmetrics:uibarmetricsdefault];
4) Add title
Self.title = @ "First page";
Add a Segmentedcontrol
Uisegmentedcontrol *segment = [[Uisegmentedcontrol alloc]initwithitems:[nsarray arraywithobjects:@ "message", @ "call", Nil]];
[Self.view addsubview:segment];
The previous step simply adds segment to the Navigation view.
The following sentence is added to the status bar
Self.navigationItem.titleView = segment;
Add buttons around
Self.navigationItem.leftBarButtonItem = [[Uibarbuttonitem alloc]initwithimage:[uiimage imagenamed:@] Iconfont-locationfill.png "] Style:uibarbuttonitemstyleplain target:self Action: @selector (Sayhi)];
Self.navigationItem.rightBarButtonItem = [[Uibarbuttonitem alloc]initwithtitle:@ "Next" style: Uibarbuttonitemstyleplain target:self Action: @selector (Sayhi)];
[Self.navigationItem.rightBarButtonItem settitletextattributes:[nsdictionary dictionarywithobjectsandkeys:[ Uicolor Greencolor], nsforegroundcolorattributename, [Uifont fontwithname:@ "Zapfino" size:18], NSFontAttributeName, NIL] forstate:uicontrolstatenormal];
At this point, the related properties of the status bar are finished!
IOS---Uinavigationcontroller