您所在的位置:小祥子 » 编程 » IOS » 正文

storyboard

时间:2015-07-24 编辑:hzroma 来源:Cnblogs

一,代码动态改写

1,一般程序启动就自动执行 main.storyboard

也可以在AppDelegate改写

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];

    // Override point for customization after application launch.

    

    //使用Storyboard初始化根界面

//    UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];

//    self.window.rootViewController = [storyBoard instantiateInitialViewController];

2,xib里调用storyboard

- (IBAction)loginBtnClicked:(id)sender {

    //点击登陆按钮后切换到storyboard界面

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];

//    self.view.window.rootViewController = [storyboard instantiateInitialViewController];

//    [self presentModalViewController:[storyboard instantiateInitialViewController] animated:YES];

    [self presentViewController:[storyboard instantiateInitialViewController] animated:YES completion:nil];

    

    [storyboard release];

}

3,storyboard调用storyboard

    1. - (IBAction)openStoryboard:(id)sender {
    2.     UIStoryboard *secondStoryboard = [UIStoryboard storyboardWithName:@"SecondStoryboard" bundle:nil];
    3.     [self presentModalViewController:[secondStoryboard instantiateInitialViewController] animated:YES];
    4. }

4.

push segue 

是将另一个视图控制器压入到导航控制器的栈中。它通常和导航视图控制器(navigation view controller)一起使用。
新压入的视图控制器会有一个回退按钮,可以退回来上一层

modal segue

跳转到vc

使用performSegueWithIdentifier來切換ViewController

http://luckfox.iteye.com/blog/1826416

custom自定义,很少用

参考:

http://iaiai.iteye.com/blog/1493956     可惜实例无法下载

 

关键词:or