美文网首页
Xcode11 删除Storyboard 之后黑屏

Xcode11 删除Storyboard 之后黑屏

作者: 赵哥窟 | 来源:发表于2020-07-08 17:31 被阅读0次

今天新写一个项目,不需要Storyboard,本以为很简单,删除之后黑屏踩了一个坑,在此记录一下。这个解决办法不一定是正确,但是这么做确实可行。

第一步

选中Main.storyboard删除

第二步

Main Interface 删除Main


截屏2020-07-08 17.22.57.png
第三步

info.plist
Application Scene Manifest 点减号删除


截屏2020-07-08 17.24.05.png
第四步

删除SceneDelegate文件


截屏2020-07-08 17.21.06.png
第五步

AppDelegate 文件注释或删除以下代码

#pragma mark - UISceneSession lifecycle


- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options {
    // Called when a new scene session is being created.
    // Use this method to select a configuration to create the new scene with.
    return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role];
}


- (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet<UISceneSession *> *)sceneSessions {
    // Called when the user discards a scene session.
    // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
    // Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}

第六步

给AppDelegate添加属性window

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow * window;

@end
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.

       self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    
        UIViewController *rootVc = [[UIViewController alloc]init];
        UINavigationController *rootNav = [[UINavigationController alloc]initWithRootViewController:rootVc];
        [self.window setRootViewController:rootNav];
        [self.window makeKeyAndVisible];
    
    return YES;
}

相关文章

网友评论

      本文标题:Xcode11 删除Storyboard 之后黑屏

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