Way one: The segues way of storyboard
Mouse click button and then control key to drag to the Svc 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.
Mode two: Tab Uitabbarcontroller Controller
Add a child controller by calling the Addchildviewcontroller method of Uitabbarcontroller, with the following code example:
| 12345678910 |
UITabBarController *tabbarVC = [[ UITabBarController alloc ] init ];FirstViewController *FVC = [[FirstViewController ] init ];FVC.tabBarItem.title = @"控制器1" ;FVC.tabBarItem.image = [ UIImage imageNamed : @"first.png" ];SecondViewController *SVC = [[SecondViewController ] init ];SVC.tabBarItem.title = @"控制器2" ;SVC. tabBarItem.image = [UIImage imageNamed : @"new.png" ];// 添加子控制器(这些子控制器会自动添加到UITabBarController的 viewControllers 数组中)[tabbarVC addChildViewController :FVC];[tabbarVC addChildViewController :SVC]; |
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
Mode three: Navigation controller Uinavigationcontroller
Called in the listener method of the FVC button:
| 1 |
[self.navigationController pushViewController:newC animated:YES]; //跳转到下一页面 |
Called in the method of the SVC:
| 1 |
[self.navigationController popViewControllerAnimated:YES]; //返回上一页面 |
When there are multiple jumps occurring and you want to return the root controller, call:
| 1 |
[ self .navigationController popToRootViewControllerAnimated: YES ]; //返回根控制器,即最开始的页面 |
Mode four: Using Modal form to display the controller
Called in FVC:
| 1 |
[ self presentViewController:SVC animated: YES completion:nil]; |
Called in the SVC:
| 1 |
[ self dismissViewControllerAnimated: YES completion: nil ]; |
Mode five: Direct changes to UIWindow's Rootviewcontroller summary:
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
Summary of Jump methods between iOS interface