Overview of how to jump between iOS pages

Source: Internet
Author: User

Transferred from: http://www.cnblogs.com/anywherego/p/3542202.html

Below with Oldviewcontroller (OLDC) button btn Click to jump to Newviewcontroller (NEWC) as an example of the explanation:

segues mode of 1.Storyboard

Click the mouse button btn and then control-drag to Newc page, in the pop-up Segue page Select the Jump mode can be

Advantages: Easy to operate, no code generation, show logic clear in storyboard

Disadvantage: When the page is not easy to view, team cooperation can be poor maintenance, many people do not recommend the use of this method of cooperation

2. TAB Uitabbarcontroller Controller

Adding a child controller by calling the Addchildviewcontroller method of Uitabbarcontroller

Instance code:

Uitabbarcontroller *TABBARVC = [[Uitabbarcontrolleralloc] init];

Oldviewcontroller *OLDC = [[oldviewcontroller] init];

Oldc. Tabbaritem. title = @ "Controller 1";

Oldc. Tabbaritem. Image = [UIImageimagenamed: @ "Old.png"];

Newviewcontroller *NEWC = [[Newviewcontroller] init];

Newc. Tabbaritem. title = @ "Controller 2";

Newc.tabbaritem. Image = [UIImageimagenamed:@ "New.png"];

//Add child controllers (these sub-controllers are automatically added to the viewcontrollers array of Uitabbarcontroller)

[TABBARVC addchildviewcontroller:recent];

[TABBARVC addchildviewcontroller:friends];

Pros: Low Code volume

Cons: Tabbar iOS native style is not very good-looking, (not commonly used, currently not recommended), if you want to use, it is recommended to customize Tabbar

3. Navigation Controller Uinavigationcontroller

Called in the OLDC Btn's listener method:

[Self.navigationcontroller PUSHVIEWCONTROLLER:NEWC Animated:yes]; Skip to Next page

Called in the method of NEWC:

[Self.navigationcontroller Popviewcontrolleranimated:yes]; Back to previous page

When there are multiple jumps occurring and you want to return the root controller, call:

[self.navigationcontroller poptorootviewcontrolleranimated:YES]; Returns the root controller, which is the first page

4. Use modal form to display the controller

Called in OLDC:

[Selfpresentviewcontroller:newc animated:YES Completion:nil];

Called in NEWC:

[Selfdismissviewcontrolleranimated:YES Completion:nil];

5. Change the Rootviewcontroller of UIWindow directly

Summarize:

Storyboard method is suitable for personal development of small programs, team work or large projects are not recommended to use

Uitabbarcontroller because the native style of the system is not very beautiful at present, it is not recommended to use

The recommended use of Uinavigationcontroller and modal, no obvious disadvantage, and most of the current programs use both methods, just to see if you need to navigate the controller and determine which scheme to use

Overview of how to jump between iOS pages

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.