欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

IOS开发(4)xcode9.2 删除项目默认的Main.storyboard

程序员文章站 2024-03-23 21:14:52
...

xcode9.2取消的创建空项目,我们可以创建Single View App 然后删除默认Main.storyboard
这样程序运行起来是黑屏。

删除步骤

删除info.plist文件中Main storyboard file base name

Key为Main storyboard file base name
Value为Main

IOS开发(4)xcode9.2 删除项目默认的Main.storyboard

删除Main.storyboard文件

在项目列表找到Main.storyboard删除

IOS开发(4)xcode9.2 删除项目默认的Main.storyboard

运行程序

程序运行显示黑屏
我们可以添加代码

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] init];
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];

    return YES;
}

程序运行会提示:

Application windows are expected to have a root view controller at the end of application launch

大概意思是应用程序期望拥有一个根控制器(RootViewController)

修改上面的代码,随便添加了一个控制器,程序就不抱错了

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.backgroundColor = [UIColor whiteColor];

    UITabBarController *tbc = [[UITabBarController alloc] init];

    self.window.rootViewController = tbc;

    [self.window makeKeyAndVisible];

    return YES;
}
相关标签: IOS