您好,登录后才能下订单哦!
步骤一:手动初始化storyboard.
首先删除系统自动创建的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。
首先删除系统自动创建的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;
}
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。