ios系统兼容

详解SceneDelegate和Man.storyboard的删

2021-08-31  本文已影响0人  逆风g

自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];
    }
    
}
上一篇下一篇

猜你喜欢

热点阅读