当前位置: 代码迷 >> 综合 >> IOS开发(4)xcode9.2 删除项目默认的Main.storyboard
  详细解决方案

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

热度:92   发布时间:2024-01-05 12:09:08.0

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

删除步骤

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

Key为Main storyboard file base name
Value为Main

删除

删除Main.storyboard文件

在项目列表找到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;
}
  相关解决方案