XCode11新增SceneDelegate

新情况

更新到XCode11之后,老项目没关系,但是新建项目,和以前完全不一样了。增加了SceneDelegate,据说是为了iPad的多进程准备的。

image.png

AppDelegate.m中增加了关于SceneDelegate的函数。

#pragma mark - UISceneSession lifecycle


- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options {
    // Called when a new scene session is being created.
    // Use this method to select a configuration to create the new scene with.
    return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role];
}


- (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet *)sceneSessions {
    // Called when the user discards a scene session.
    // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
    // Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}

去掉不需要的SceneDelegate

如果没有多进程需求,那么还是去掉这个多余的SceneDelegate比较好。

  • 直接删除SceneDelegate文件,包括.h,.m

  • 删除info.plist中的Application Scene Manifest选项

  • 删除AppDelegate.m中关于SceneDelegate的函数。

  • AppDelegate.h中添加window属性

@property (strong, nonatomic) UIWindow *window;

没有window属性,会导致黑屏

  • 设置最低支持版本,比如9.0;最好不要用8.0,太低了,有未知的问题。
image.png

多进程等以后成熟了再说,并且最低支持版本最好是iOS13

你可能感兴趣的:(XCode11新增SceneDelegate)