Xcode更新增加了SceneDelegate文件,現(xiàn)在創(chuàng)建一個(gè)新的項(xiàng)目會(huì)出現(xiàn)一下情況(xcode版本11.3)

iOS13之前,Appdelegate的作用是全權(quán)處理App生命周期和UI生命周期;
?iOS13之后,Appdelegate的作用是只處理 App 生命周期, 而UI的生命周期將全權(quán)由新增的SceneDelegate來(lái)處理.這里就教大家如何刪除SceneDelegate;
1.在項(xiàng)目的info.plist文件右鍵,Open As --> Source Code打開plist文件,如圖:

2.刪除SceneDelegate相關(guān)配置,如圖所示

3.然后再項(xiàng)目中刪除掉SceneDelegate.h和SceneDelegate.m文件;delete --> Move to Trash

4.然后刪除或者注釋掉AppDelagate.m文件中UISceneSession lifecycle方法

5.在AppDelagate.h文件中加入U(xiǎn)IWindow屬性

到這里就完成了SceneDelegate文件的刪除工作,如果需要自定義ViewController,繼續(xù)往下:
6.選中Main.storyboard,然后選中xib頁(yè)面,在右側(cè)去掉Is Initial View Controller勾選

7.然后選中項(xiàng)目中viewController.h和.m文件以及Main.storyboard和LaunchScreen.storyboard,郵件delete -->Move to Trash

8.創(chuàng)建自定義根視圖(這里是RootViewController,根據(jù)自己需求設(shè)置)

9.設(shè)置帶導(dǎo)航欄的RootViewController根視圖

10.然后需要將general中的Main Interface和Launch Screen File置空

11.在項(xiàng)目info.plist中添加key:Launch screen interface file base name(不添加會(huì)出現(xiàn)上下黑邊)

12.到此就大功告成
