Summary of redirection methods between ios interfaces, and summary of ios page redirection

Source: Internet
Author: User

Summary of redirection methods between ios interfaces, and summary of ios page redirection

I have been in touch with ios for a while. By accident, our company's technical director and my mentor asked me, you know, there are several ways to jump between interfaces? I said two types, but they are also a bit vague, so I want to find a time to sum up. There is a saying that "the predecessors planted trees, and future generations enjoyed the coolness". Currently, as a cool-down person, I also hope to plant some trees to create a fresh image for the code world. Okay. Let's talk about it more. Let's go to the topic.

The following uses the button of FirstViewController (FVC) to jump to SecondViewController (SVC) as an example:

Method 1: Storyboard's segues Method

Click the button, hold down the control key, and drag it to the SVC page. Select the jump mode on the pop-up seue page.

Advantages: easy operation, no code generation, clear logic displayed in storyboard
Disadvantages: it is inconvenient to view a large number of pages, and the maintainability is poor during team collaboration. This method is not recommended when many people work together.

Method 2: tab UITabBarController Controller

Call the addChildViewController method of UITabBarController to add a sub-controller. The code example is as follows:

12345678910 UITabBarController *tabbarVC = [[ UITabBarController alloc ] init ];FirstViewController *FVC = [[FirstViewController ] init ];FVC.tabBarItem.title = @"Controller 1" ;FVC.tabBarItem.image = [ UIImage imageNamed : @"first.png" ];SecondViewController *SVC = [[SecondViewController ] init ];SVC.tabBarItem.title = @"Controller 2" ;SVC. tabBarItem.image = [UIImage imageNamed : @"new.png" ];// Add sub-controllers (these sub-controllers are automatically added to the viewControllers array of UITabBarController)[tabbarVC addChildViewController :FVC];[tabbarVC addChildViewController :SVC];

Advantage: less code
Disadvantage: the native style of tabbar is not very nice (not commonly used, not recommended currently). If you want to use it, we recommend that you customize tabbar

Method 3: navigation controller UINavigationController

Call the following method in the listener method of the FVC button:

1 [self.navigationController pushViewController:newC animated:YES]; // Jump to the next page

Call the following in the SVC method:

1 [self.navigationController popViewControllerAnimated:YES]; // Return to the previous page

When multiple redirects occur and you want to return the root controller, call:

1 [ self .navigationController popToRootViewControllerAnimated: YES ];  // Return to the root controller, that is, the initial Page
Method 4: Use Modal to display controllers

Call in FVC:

1 [ self presentViewController:SVC animated: YES completion:nil];

Call in SVC:

1 [ self dismissViewControllerAnimated: YES completion: nil ];
Method 5: directly change the rootViewController of UIWindow. Conclusion:

The Storyboard method is suitable for individuals who develop small programs. It is not recommended to use it if they have team cooperation or large projects.
UITabBarController is not recommended because the system's native style is not very beautiful.
We recommend that you use UINavigationController and Modal without any obvious disadvantages. Most programs currently use these two methods to determine which solution to use only by checking whether the navigation controller is required.

Permanent address: http://blog.it985.com/13090.html
This article is from the IT985 blog. Please indicate the source and relevant links when reprinting.

Related Article

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.