iOS Development: Multi-controller Management in iOS

Source: Internet
Author: User

There are three ways to create a controller in iOS:

1. Create with Storyboard
Uistoryboard *storyboard = [Uistoryboard storyboardwithname:@ "Apply"*SCHEMEVC = [Storyboard Instantiateviewcontrollerwithidentifier:@ "schemeviewcontroller"];
2. Specify the Xib file to create
Yfviewcontroller *MJ = [[Yfviewcontroller alloc] Initwithnibname:@ "yfviewcontroller" Bundle:nil];
3. Create directly
Yfviewcontroller *MJ = [[Yfviewcontroller alloc] init];
An iOS app rarely consists of a single controller, unless the app is extremely simple, and when there are multiple controllers in the app, we need to manage these controllers, there are multiple view, you can use a large view to manage 1 or more small view, the controller is the same With 1 controllers to manage the other multiple controllers, for example, with a controller A to manage 3 controllers B, C, D, controller A is called Controller B, C, D "Parent Controller", Controller B, C, D is called controller A "sub-controller", in order to facilitate the management of the controller, iOS offers 2 more special controllers, Uinavigationcontroller and Uitabbarcontroller. Uinavigationcontroller Saving a sub-controller as a stack • Use the push method to push a controller into the stack
-(void) Pushviewcontroller: (Uiviewcontroller *) Viewcontroller animated: (BOOL) animated;
• Use the Pop method to remove the controller
// Remove the controller from the top of the stack -(Uiviewcontroller *) popviewcontrolleranimated: (BOOL) animated; // back to the specified sub-controller -(Nsarray *) Poptoviewcontroller: (Uiviewcontroller *) Viewcontroller animated: (BOOL) animated; // Back to root controller (stack bottom controller)-(Nsarray *) poptorootviewcontrolleranimated: (BOOL) animated;
• The contents of the navigation bar are determined by the Navigationitem property of the top controller, Uinavigationitem has the following properties affecting 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; // the middle title text @property (nonatomic,copy)   nsstring        *title; // the view in the upper-left corner @property (nonatomic,retain) uibarbuttonitem * *rightbarbuttonitem   // the upper right corner of the view @property (nonatomic,retain) Uibarbuttonitem *rightbarbuttonitem;

View loading process in controller: The method called by the controller's view load during the entire life cycle: memory warning Processing:

iOS Development: Multi-controller Management in iOS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.