步骤一:手动初始化storyboard.

  1. 首先删除系统自动创建的ViewController.h, ViewController.m 和 main.storyboard这三个文件。

   2.  点击项目——>General——>Deployment Info,在Main Interface选项中将main删除。

   3.   新建一个Storyboard文件,拖一个控制器,在拖一个按钮。点击storyboard上方的导航条,在右侧“属性”栏下view Controller复选框中Title下方将“Is  Initial View Controller”勾选上。

   4.    在AppDelegate.m文件中的didFinishLaunchingWithOptions方法中填写下面代码:

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

   

//    1. Create a window

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

    

//    2. Create Controller(A StoryBoard)

    UIStoryboard *story = [UIStoryboard storyboardWithName:@"Storyboard" bundle:nil];

    

//    2.1 Instantiate Controller (With Sweet(jian tou))

    UIViewController *vc = [story instantiateInitialViewController];

    

//    3. Set the window Root Controller

    self.window.rootViewController = vc;

    

//    4. Put the window as the Main Window and visible

    [self.window makeKeyAndVisible];

    

    return YES;

}

步骤二:通过标记初始化storyboard。

  1. 首先删除系统自动创建的ViewController.h, ViewController.m 和 main.storyboard这三个文件。

   2.  点击项目——>General——>Deployment Info,在Main Interface选项中将main删除。

   3.   新建一个Storyboard文件,拖一个控制器,在拖一个按钮。点击storyboard上方的导航条,在右侧“属性”栏左侧选项中identity选项下storyboard ID里填写“Vstar”,之后点击回车键。

   4.    在AppDelegate.m文件中的didFinishLaunchingWithOptions方法中填写下面代码:

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

   

//    1. Create a window

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

    

//    2. Create Controller(A StoryBoard)

    UIStoryboard *story = [UIStoryboard storyboardWithName:@"Storyboard" bundle:nil];

    

//    2.1 Instantiate Controller (With Sweet(jian tou))

    UIViewController *vc = [story instantiateViewControllerWithIdentifier:@"Vstar"];

    

//    3. Set the window Root Controller

    self.window.rootViewController = vc;

    

//    4. Put the window as the Main Window and visible

    [self.window makeKeyAndVisible];

    

    return YES;

}