一、 storyboard的sugues方式;
优点:操作方便,无代码生成,在storyboard中展示逻辑清晰
缺点:页面较多时不方便查看,团队合作时可维护性差, 多人合作时不建议使用这种方式。
二、选项卡UITabBarController
通过调用UITabBarController的addChildViewController方法添加子控制器,代码实例如下:
|
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];
|
优点:代码量较少
缺点:tabbar的ios原生样式不太好看,(不常用,目前不建议使用),如果要使用,建议自定义tabbar
[self.navigationController pushViewController:newC animated:YES];
//跳转到下一页面
[self.navigationController popViewControllerAnimated:YES];
//返回上一页面 (自带有back)
[ self .navigationController popToRootViewControllerAnimated: YES ];
//返回根控制器,即最开始的页面
四、
[ self presentViewController:SVC animated: YES completion:nil];//跳转
[ self dismissViewControllerAnimated: YES completion: nil ];//返回
五、
self.window.rootViewController