1.新建项目后,选中项目名称,在配置栏中选择Info栏目,在Custom iOS Target Properties子栏目中删除Main storyboard file base name项。
2.新建根视图文件,在
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
}
方法中加入如下代码:
self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
[self.window makeKeyAndVisible];
OneViewController *oneView = [[OneViewController alloc]init];
UINavigationController *navc = [[UINavigationController alloc]initWithRootViewController:oneView];
self.window.rootViewController = navc;
return YES;
现在即完成了根视图的设置。
注: OneViewController只是类名随意起。
若是不需要navigationController只需要在方法中加上如下代码:
[self.navigationController setNavigationBarHidden:TRUE];
iOS开发:Xcode设置根视图教程
本文介绍了在Xcode中设置根视图的步骤。首先,删除Info栏目中的Main storyboard file base name项,然后新建根视图文件。在`application:didFinishLaunchingWithOptions:`方法中添加代码以设置根视图控制器。
525

被折叠的 条评论
为什么被折叠?



