xcode 11 APPdelegate适配ios9

如果我们不开发iPadOS多窗口APP,SceneDelegate窗口管理我们可以不需要直接删掉就好了。

  1. 删除掉info.plist中Application Scene Manifest选项,同时,文件SceneDelegate可删除可不删

相关代码注释

	func application(_ application: UIApplication, 	configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
        return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
    }

    func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
    }
    //注释掉这两个方法。

如果我们开发iPadOS多窗口APP,SceneDelegate窗口管理我们可以不需要直接删掉就好了。

    1.如果系统是ios13以下的,直接在APPdelegate中进行判断,因为ios13,APPdelegate中没有window属性,需要重新添加window属性,创建window

if (@available(ios 13, *)) {
        
    }else{
        self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
        
        [self detectNetwork];

        CLTabbarController *tabbarVC = [[CLTabbarController alloc]init];
        CLBaseNavigationController *baseVC = [[CLBaseNavigationController alloc]initWithRootViewController:tabbarVC];
        self.window.rootViewController = baseVC;
        
        [self.window makeKeyAndVisible];

    }

xcode11新增了SceneDelegate 方法

如果是ios13系统,系统走以下方法

- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions  API_AVAILABLE(ios(13.0)){
    // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
    // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
    // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
    
    [self detectNetwork];

    UIWindowScene *windowScene = (UIWindowScene *)scene;
    self.window = [[UIWindow alloc] initWithWindowScene:windowScene];
    self.window.backgroundColor = [UIColor whiteColor];
    
    CLTabbarController *tabbarVC = [[CLTabbarController alloc]init];
    CLBaseNavigationController *baseVC = [[CLBaseNavigationController alloc]initWithRootViewController:tabbarVC];
    self.window.rootViewController = baseVC;
    
    [self.window makeKeyAndVisible];

}

剩下就能按照之前项目的步骤进行开发了。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值