iOS 一一 根据storyBoard加载window根控制器的View

来源:互联网 发布:淘宝海外直邮是正品吗 编辑:程序博客网 时间:2024/05/16 16:13


1.加载指定的storyBoard

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

2.加载箭头所指向的控制器.

UIViewController *vc = [storyBoard instantiateInitialViewController];

3.加载指定标识的控制器.

UIViewController *vc = [storyBoard instantiateViewControllerWithIdentifier:@"VCStoryBoardID"];




- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {        // 通过storyBoard加载控制器(通过storyBoard来加载Window根控制器的view)        //1. 创建窗口    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];        //2. 设置窗口的根控制器    //2.1创建storyBoard对象    UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];        //2.2 加载storyBoard箭头指向的控制器//    UIViewController *vc = [storyBoard instantiateInitialViewController];    //2.3 加载storyBoard中指定的控制器    UIViewController *vc = [storyBoard instantiateViewControllerWithIdentifier:@"ZY"];    self.window.rootViewController = vc;        //3. 显示窗口    [self.window makeKeyAndVisible];            return YES;}



阅读全文
0 0