IOS删除SceneDelegate

2023-10-30  本文已影响0人  ChaosHeart

删除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];
上一篇下一篇

猜你喜欢

热点阅读