删除SceneDelegate
1.首先选中SceneDelegate.h和SceneDelegate.m类,右击选择Delete,选择"Move to Trash";
image2.打开Info.plist文件,点击"Application Scene Mainfest"的➖号按钮删除该项;
image3.点击打开TARGETS->General,清空”App Icons and Lanuch Images“下的”Launch Screen File“选项。
image4.打开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];
网友评论