今天新写一个项目,不需要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;
}