如果我们不开发iPadOS多窗口APP,SceneDelegate窗口管理我们可以不需要直接删掉就好了。
- 删除掉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];
}
剩下就能按照之前项目的步骤进行开发了。