美文网首页
iOS 解决移除Main storyboard入口屏幕黑屏问题

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

作者: 黑黝黝的搬砖王 | 来源:发表于2018-08-02 15:08 被阅读0次

遇到移除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入口屏幕黑屏问题

      本文链接:https://www.haomeiwen.com/subject/xttsvftx.html