美文网首页
XCode11新增SceneDelegate

XCode11新增SceneDelegate

作者: 勇往直前888 | 来源:发表于2019-11-11 10:14 被阅读0次

    新情况

    更新到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

    相关文章

      网友评论

          本文标题:XCode11新增SceneDelegate

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