在興沖沖更新了Xcode11,并建立了項目之後,且發現真機和模拟器都黑屏了,怎麼都不顯示View了。
然後項目中比之前莫名其妙的多出來了兩個檔案:
![](https://img.laitimes.com/img/9ZDMuAjOiMmIsIjOiQnIsICM38FdsYkRGZkRG9lcvx2bjxiNx8VZ6l2cs0TPB9kMZpXT10keNpHOslVModEZwRmMMBjVtJWd0ckW65UbM5WOHJWa5kHT20ESjBjUIF2X0hXZ0xCMx81dvRWYoNHLrdEZwZ1Rh5WNXp1bwNjW1ZUba9VZwlHdssmch1mclRXY39CXldWYtlWPzNXZj9mcw1ycz9WL49zZuBnL2ADN2UDMwAjMyADMxkTMwIzLc52YucWbp5GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.png)
APPdelegate.m中也多了兩段不明是以的代碼:
#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.
}
經查詢資料得知,IOS13之後,生命周期時間就開始由
UISceneDelegate
接管了,一時間真的是措手不及啊,不過适應之前可以先通過以下辦法恢複到原來的項目結構:
- 删除info.plist中的
Application Scene Manifest
xcode11建立新項目時,黑屏了,不顯示View - 删除項目中的Scenedelegate.h和Scenedelegate.m
- 删除掉APPdelegate.m中的
代碼#pragma mark - UISceneSession lifecycle
- 在APPdelegate.h中添加
屬性@property (strong, nonatomic) UIWindow * window;
然後,老朋友就還是熟悉的項目,熟悉的味道了。