OC環(huán)境下:
1.先直接刪除SceneDelegate.h/.m文件
2.在AppDelegate.h添加@property (strong, nonatomic) UIWindow * window;屬性
#import
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow * window;
@end
3.移除UIScene代理
移除之前
#import "AppDelegate.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication*)applicationdidFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
? ? // Override point for customization after application launch.
? ? return YES;
}
#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*)applicationdidDiscardSceneSessions:(NSSet *)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.
}
@end
移除之后
#import "AppDelegate.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication*)applicationdidFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
? ? // Override point for customization after application launch.
? ? return YES;
}
@end
4.最后在info.plist文件中移除Application Scene Manifest
Swift環(huán)境下也是一樣的:
1.先直接刪除SceneDelegate.swift文件
2.在info.plist文件中刪除Application scene manifest
3.刪除AppDelegate中的兩個(gè)方法
4.在Appdelegate中增加window屬性
知識(shí)補(bǔ)充:SceneDelegate
Xcode 11 建新工程默認(rèn)會(huì)創(chuàng)建通過(guò) UIScene 管理多個(gè) UIWindow 的應(yīng)用,工程中除了 AppDelegate 外還會(huì)有一個(gè) SceneDelegate,這是為了實(shí)現(xiàn)iPadOS支持多窗口的結(jié)果。如果僅開發(fā)iPhone應(yīng)用而非iPad,那么該文件可放心地刪除。