Uinavigationcontroller&uitabbarcontroller detailed
One: Uinavigationcontroller
Properties of the controller:
Uinavigationcontroller to save the sub-controller in the form of a stack
- @property (nonatomic,copy) Nsarray *viewcontrollers;
- @property (nonatomic,readonly) Nsarray *childviewcontrollers;
Jump between navigation controllers:
Use the push method to push a controller into the stack
- -(void) Pushviewcontroller: (Uiviewcontroller *) Viewcontroller animated: (BOOL) animated;
Use the Pop square method to remove the controller
Remove the controller from the top of the stack
- -(Uiviewcontroller *) popviewcontrolleranimated: (BOOL) animated;
Back to the specified child controller
- -(Nsarray *) Poptoviewcontroller: (Uiviewcontroller *) Viewcontroller animated: (BOOL) animated;
Back to root controller (stack bottom controller)
- -(Nsarray *) poptorootviewcontrolleranimated: (BOOL) animated;
Common controller (navigation) property settings
The contents of the navigation bar are determined by the Navigationitem property of the stack top controller
Uinavigationitem has the following properties that affect the contents of the navigation bar
The Back button in the upper-left corner
- @property (Nonatomic,retain) Uibarbuttonitem *backbarbuttonitem;
The middle title view
- @property (Nonatomic,retain) UIView *titleview;
Middle Caption text
- @property (nonatomic,copy) NSString *title;
The view in the upper-left corner
- @property (Nonatomic,retain) Uibarbuttonitem *leftbarbuttonitem;
Uibarbuttonitem *rightbarbuttonitem view in the upper right corner
- @property (Nonatomic,retain) Uibarbuttonitem *rightbarbuttonitem;
Segue Properties (each line on the storyboard for interface jumps is a Uistoryboardsegue object (Segue))
According to Segue's execution (jump) moment, segue can be divided into 2 major types
- Auto-type: After clicking on a control (such as a button), automatic execution of Segue, auto-complete interface jump
- Manual type: Need to write code to manually perform segue to complete the interface jump
Segue Property
- Uniquely identifies
- @property (nonatomic, readonly) NSString *identifier;
- SOURCE Controller
- @property (nonatomic, readonly) ID Sourceviewcontroller;
- Target Controller
- @property (nonatomic, readonly) ID Destinationviewcontroller;
Segue method
- [Self performseguewithidentifier:@ "login2contacts" sender:nil];
- The segue must be executed by the source controller, which means that the perform method must be called by the source controller
- -(void) Prepareforsegue: (Uistoryboardsegue *) Segue Sender: (ID) sender;
- [Self performseguewithidentifier:@ "login2contacts" sender:@ "Jack"];
Two: Uitabbarcontroller
Uitabbarcontroller Steps to use
- Initialize Uitabbarcontroller
- Set the Rootviewcontroller for UIWindow to Uitabbarcontroller
- Depending on the case, add the corresponding number of sub-controllers by the Addchildviewcontroller method
There are 2 ways to add a Uitabbarcontroller controller
Adding a single child controller
- -(void) Addchildviewcontroller: (Uiviewcontroller *) Childcontroller;
Set up a sub-controller array
- @property (nonatomic,copy) Nsarray *viewcontrollers;
Note:what is displayed inside the Uitabbarbutton is determined by the Tabbaritem property of the corresponding sub-controller
Uitabbaritem has the following properties that affect the content of Uitabbarbutton
- Title text
- @property (nonatomic,copy) NSString *title;
- Icon
- @property (Nonatomic,retain) UIImage *image;
- Icon When selected
- @property (Nonatomic,retain) UIImage *selectedimage;
- Reminder numbers
- @property (nonatomic,copy) NSString *badgevalue;
How the controller is presented (important in development)
Display the controller in the form of modal
- -(void) Presentviewcontroller: (Uiviewcontroller *) viewcontrollertopresent animated: (BOOL) flag completion: (void (^) ( void)) Completion
Shut down the modal controller.
- -(void) dismissviewcontrolleranimated: (BOOL) flag completion: (void (^) (void)) completion;
Three: Uinavigationcontroller&uitabbarcontroller use combat:
This article is just a brief introduction about Uinavigationcontroller drink Uitabbarcontroller Some of the common attribute methods and use of skills, about basic use and actual combat article, please look at the following article, I'm going to use two controllers in the future to implement the mainstream framework for iOS development in real-world development:
is actually the equivalent of the development of our project environment in the construction of the app
Playing Uinavigationcontroller and Uitabbarcontroller of environment construction
The pure Code of Environment construction: http://www.cnblogs.com/iCocos/p/4690677.html
The xib:http://www.cnblogs.com/icocos/p/4690714.html of environmental construction
The storyboard:http://www.cnblogs.com/icocos/p/4690659.html of environmental construction
iOS Development--Controller OC Chapter &uinavigationcontroller&uitabbarcontroller detailed