緊接3.8特殊節(jié)日的文章Xcode 11新建項(xiàng)目,繼續(xù)學(xué)習(xí)
自xcode11新增SceneDelegate后土辩,SceneDelegate與Man.storyboard該如何處理:
1. 第一種情況支救,刪除SceneDelegate,但保留Man.storyboard:
- 刪除info.plist中的
Application Scene Manifest
一項(xiàng) - 在AppDelegate.h中添加window屬性
@property (strong, nonatomic) UIWindow *window;
- 刪除AppDelegate.m中新增的兩個(gè)UIScene方法
- 刪除UISceneDelegate類(lèi)文件
切記要在AppDelegate.h中添加window屬性拷淘,否則Man.storyboard無(wú)法正常加載
2. 第二種情況各墨,刪除SceneDelegate且刪除Man.storyboard:
- 刪除info.plist中的
Application Scene Manifest
一項(xiàng) - 在AppDelegate.h中添加window屬性
@property (strong, nonatomic) UIWindow *window;}
- 刪除AppDelegate.m中新增的兩個(gè)UIScene方法
- 刪除UISceneDelegate類(lèi)文件
- 刪除Main.storeboaard文件
- 項(xiàng)目
TARGETS->General->Main Interface
置為空 - 刪除info.plist中
Main storyboard file base name
一項(xiàng) - AppDelegate.m中導(dǎo)入目標(biāo)頭文件,在
didFinishLaunchingWithOptions
方法中添加目標(biāo)類(lèi):
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
self.window = [[UIWindow alloc] init];
self.window.frame = [UIScreen mainScreen].bounds;
self.window.backgroundColor = [UIColor whiteColor];
ViewController * vc = [[ViewController alloc]init];
self.window.rootViewController = vc;
[self.window makeKeyAndVisible];
return YES;
}
3. 第三種情況启涯,保留SceneDelegate但刪除Man.storyboard:
- 項(xiàng)目
TARGETS->General->Main Interface
置為空 - 刪除info.plist中
Main storyboard file base name
一項(xiàng) - 刪除info.plist中
Application Scene Manifest -> Scene Configuration -> Application Scene Role -> Item 0 -> Storyboard name
一項(xiàng) - SceneDelegate.m中導(dǎo)入目標(biāo)頭文件贬堵,在
willConnectToSession
方法中添加目標(biāo)類(lèi):
- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
if ([scene isKindOfClass:[UIWindowScene class]]) {
UIWindowScene *windowScene = (UIWindowScene*)scene;
self.window = [[UIWindow alloc] initWithWindowScene:windowScene];
self.window.frame = [UIScreen mainScreen].bounds;
self.window.backgroundColor = [UIColor whiteColor];
ViewController * vc = [[ViewController alloc]init];
self.window.rootViewController = vc;
[self.window makeKeyAndVisible];
}
}