iOS SBios

StoryBoard

2016-01-21  本文已影响485人  俊月

1.第一个项目用的是xib,一个页面包含3个部分【.h .m .xib】

2.第二个项目用的是storyboard.
3.有四个模块,然后我们用了4个storyboard,每个storyboard含有一个NavigationController。
4.用UITabBarController做这四个storyboard的【container view controller】容器。
5.最后把UITabBarController 设为window.rootViewController 。

UITabBarController *tabBar = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateInitialViewController];

UINavigationController *firstVC = [[UIStoryboard storyboardWithName:@"VCStoryboard" bundle:nil] instantiateInitialViewController];


UINavigationController *secondVC = [[UIStoryboard storyboardWithName:@"SecondStoryboard" bundle:nil] instantiateInitialViewController];
UINavigationController *thirdVC = [[UIStoryboard storyboardWithName:@"ThirdStoryboard" bundle:nil] instantiateInitialViewController];
UINavigationController *fourthVc = [[UIStoryboard storyboardWithName:@"Fourth" bundle:nil] instantiateInitialViewController];
UINavigationController *fifthVc = [[UIStoryboard storyboardWithName:@"Fifth" bundle:nil] instantiateInitialViewController];

tabBar.viewControllers = @[firstVC,secondVC,thirdVC,fourthVc,fifthVc];

self.window.rootViewController = tabBar;

Paste_Image.png

知识铺垫
storyboard 把 view controller叫做:“scene”.(场景)
storyboard可以描述各种场景之间的过渡,这种过渡被称作"segue",你通过简单的ctrl-dragging就能搞定,减少代码量。
storyboard支持table view的prototype cell,这意味着你可以在storyboard中编辑cell,直接在tableView 中建立cell 的xib,减少代码量。
更改初始化vc 【is initial view controller】
只有给scene 设置 完class ,才可以向对应的.h 或.m 拖拽。
页面跳转(A页面的button 点击跳转B页面)
①在StoryBoard的某个scene中 A页面的button 直接往B页面上拖拽,
弹出页面,选择跳转方式,就完成了页面的跳转
②使用代码进行跳转
把界面缩小(你可以在空白的地方双击一下,或者右键选择缩放比例)
把A页面往B页面拖拽,弹出页面,选择跳转方式。此时产生A页面过度到B页面的segue。设置segue 的identifier (唯一标识),在A页面的button 的点击事件下写入代码

[self performSegueWithIdentifier:@"segueIdentifier" sender:self];

页面传值
① 使用- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender; 进行传值

上一篇下一篇

猜你喜欢

热点阅读