美文网首页
IOS删除SceneDelegate

IOS删除SceneDelegate

作者: ChaosHeart | 来源:发表于2023-10-30 11:48 被阅读0次

    删除SceneDelegate

    1.首先选中SceneDelegate.h和SceneDelegate.m类,右击选择Delete,选择"Move to Trash";

    image

    2.打开Info.plist文件,点击"Application Scene Mainfest"的➖号按钮删除该项;

    image

    3.点击打开TARGETS->General,清空”App Icons and Lanuch Images“下的”Launch Screen File“选项。

    image

    4.打开AppDelegate.h文件,声明UIWindow对象

    @interface AppDelegate : UIResponder <UIApplicationDelegate>
    @property (strong, nonatomic) UIWindow *window;
    @end
    
    

    5.打开AppDelegate.m文件,删除以下SceneDelegate的两个代理方法

    - (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options
     {
        return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role];
    }
    - (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet<UISceneSession *> *)sceneSessions
    {
    }
    
    

    然后在didFinishLaunchingWithOptions方法里设置rootViewController即可。

    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.window.backgroundColor = UIColor.redColor;
    UIViewController *vc = [[UIViewController alloc] init];
    self.window.rootViewController = vc;
    [self.window makeKeyAndVisible];
    

    相关文章

      网友评论

          本文标题:IOS删除SceneDelegate

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