视图控制器中之间切换的几种方式 by 李梦珂
2015-11-22 17:35
435 查看
**
-(void)presentModel
{
RootViewController *rootview = [[RootViewController alloc]init];
}
**
-(void)pushNavigation
{
SecondViewController *controller2 = [[SecondViewController alloc]init];
[self.navigationController pushViewController:controller2 animated:YES];
}
-(void)index
{
UIViewController *second = [[self.navigationController viewControllers]objectAtIndex:1];
[self.navigationController popToViewController:second animated:YES];
}
注:UInavigationController中各视图之间有层级关系,用栈的模式来管理视图控制器,而UITabBarController中各视图之间是并列关系,无层级之分。
两者混合使用时最好将UINavigationController加到UITabBarController上!
1.模态视图
**-(void)presentModel
{
RootViewController *rootview = [[RootViewController alloc]init];
rootview.modalTransitionStyle = UIModalTransitionStyleCoverVertical; [self presentViewController:rootview animated:YES completion:^{ NSLog(@"call back"); }];
}
2,UITabBarController实现并列画面跳转
self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds]; self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; UIViewController *vc1 = [[UIViewController alloc]init]; vc1.title = @"消息"; vc1.view.backgroundColor = [UIColor redColor]; UIViewController *vc2 = [[UIViewController alloc]init]; vc2.title = @"设置"; vc2.view.backgroundColor = [UIColor orangeColor]; UIViewController *vc3 = [[UIViewController alloc]init]; vc3.title = @"主页"; vc3.view.backgroundColor = [UIColor yellowColor]; UIViewController *vc4 = [[UIViewController alloc]init]; vc4.title = @"微博"; vc4.view.backgroundColor = [UIColor greenColor]; UIViewController *vc5 = [[UIViewController alloc]init]; vc5.title = @"图片"; vc5.view.backgroundColor = [UIColor blueColor]; NSArray *controller = @[vc1,vc2,vc3,vc4,vc5]; UITabBarController *tabbar = [[UITabBarController alloc]init]; tabbar.viewControllers = controller;
**
3,UINavigationController实现多层画面跳转,在导航控制器中,载入有层级关系的界面
**-(void)pushNavigation
{
SecondViewController *controller2 = [[SecondViewController alloc]init];
[self.navigationController pushViewController:controller2 animated:YES];
}
-(void)index
{
UIViewController *second = [[self.navigationController viewControllers]objectAtIndex:1];
[self.navigationController popToViewController:second animated:YES];
}
注:UInavigationController中各视图之间有层级关系,用栈的模式来管理视图控制器,而UITabBarController中各视图之间是并列关系,无层级之分。
两者混合使用时最好将UINavigationController加到UITabBarController上!
相关文章推荐
- 1017. Queueing at Bank
- 【poj2039】To and Fro
- 断点续传的原理剖析与实例讲解
- COMPSAC峰会
- ios UITableView 入门
- java IO 流 读写文件 以及复制
- Android Studio中的assets目录怎么创建?
- Easyui简单布局
- learn go defer
- 网络工程实训_2路由器基本配置及IOS介绍
- 《Go语言入门》如何在Windows下安装Go语言编程环境
- 黑马程序员 JavaSE-06 面向对象(下)
- 在mac上创建鼠标双击可执行的shell脚本
- Mysql日志详解
- UIButton
- 网络工程实训_1路由器介绍
- OpenSSH服务器端的配置文件各常用参数含义
- 博客的开始,介绍一些自己,我是这样的一个程序员
- s3c2440 usb host
- TortoiseSVN中分支和合并实践