iOS 解决移除Main storyboard入口屏幕黑屏问题

遇到移除Main Storyboard入口后运行项目屏幕黑屏的解决方案,目前版本的Xcode创建Single Application后都会生成一个Main.storyboard文件,如果我们想不使用Main.storyboard改用其它入口的话,我们就需要下面的两步操作来正确删除Main.storyboard入口的方法。

1、在工程配置中移除关联
移除工程关联
2、在AppDelegate.m- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions中重新创建UIWindow
  self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        
  ViewController *viewController = [[ViewController alloc] init];               
  self.window.rootViewController = viewController;
        
  [self.window makeKeyAndVisible];

注意:不修改Main storyboard时工程会帮我们创建好UIWindow,当我们去掉Main storyboard入口时我们就需要重新创建一下UIWindow。

你可能感兴趣的:(iOS 解决移除Main storyboard入口屏幕黑屏问题)