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<UISceneSession *> *)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

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容