Xcode11之后新創建的工程會多出兩個文件SceneDelegate。那么我們如何讓它變回之前的那樣的工程呢。
一、將這兩個文件刪除。 會報錯 There is no scene delegate set. A scene delegate class must be specified to use a main storyboard file.
二、將Info.plist -> Open As -> Source Code將划框的部分刪除。
三、將AppDelegate.m中的UISceneSession lifecycle注釋掉或者刪掉。
#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.
}
四、在didFinishLaunchingWithOptions中加入UIWindow。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
self.window.rootViewController = [[ViewController alloc] init];;
[self.window makeKeyAndVisible];
return YES;
}
<轉載自: 去掉sceneDelegate>