详解SceneDelegate和Man.storyboard的删

2022-03-08  本文已影响0人  笑笑菜鸟

紧接3.8特殊节日的文章Xcode 11新建项目,继续学习
自xcode11新增SceneDelegate后,SceneDelegate与Man.storyboard该如何处理:

1. 第一种情况,删除SceneDelegate,但保留Man.storyboard:

2. 第二种情况,删除SceneDelegate且删除Man.storyboard:


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    self.window = [[UIWindow alloc] init];
    self.window.frame = [UIScreen mainScreen].bounds;
    self.window.backgroundColor = [UIColor whiteColor];

    ViewController * vc = [[ViewController alloc]init];
    self.window.rootViewController = vc;
    [self.window makeKeyAndVisible];
    return YES;
}

3. 第三种情况,保留SceneDelegate但删除Man.storyboard:

- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
    if ([scene isKindOfClass:[UIWindowScene class]]) {
        UIWindowScene *windowScene = (UIWindowScene*)scene;
        self.window = [[UIWindow alloc] initWithWindowScene:windowScene];
        self.window.frame = [UIScreen mainScreen].bounds;
        self.window.backgroundColor = [UIColor whiteColor];

        ViewController * vc = [[ViewController alloc]init];
        self.window.rootViewController = vc;
        [self.window makeKeyAndVisible];
    }
    
}
上一篇下一篇

猜你喜欢

热点阅读