美文网首页
UIWindow(III)

UIWindow(III)

作者: Harely | 来源:发表于2019-11-20 21:09 被阅读0次

    iOS13 UIWindow 适配

    AppDelegate.m 文件

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
        if (@available(iOS 13,*)) {
                return YES;
            } else {
                self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
                UINavigationController *rootNavgationController = [[UINavigationController alloc] initWithRootViewController:[ViewController new]];
                self.window.rootViewController = rootNavgationController;
                [self.window makeKeyAndVisible];
                return YES;
            }
        
    }
    
    

    SceneDelegate.m 文件

    - (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {    
       
            self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
            self.window.windowScene = (UIWindowScene*)scene;
            UINavigationController *rootNavgationController = [[UINavigationController alloc] initWithRootViewController:[ViewController new]];
            self.window.rootViewController = rootNavgationController;
            [self.window makeKeyAndVisible];    
    }
    
    

      这样就可以兼容iOS13和iOS12的UIWindow显示了。

    相关文章

      网友评论

          本文标题:UIWindow(III)

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