IOS删除SceneDelegate

删除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];
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容