将多出来的文件和代码删除就好了
删除SceneDelegate代理文件 (可选)
删除 Info.plist里面的Application Scene Manifest配置(一定要删除)
删除 AppDelegate代理的两个方法:
application:configurationForConnectingSceneSession:options:
application: didDiscardSceneSessions:
这两个方法一定要删除,否则使用纯代码创建的不会生效。
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
window?.backgroundColor = UIColor.white;
window = UIWindow(frame: UIScreen.main.bounds);
let tabbar = MainTabBarCtrl();
window?.rootViewController = tabbar;
window?.makeKeyAndVisible()
return true
}
代码虽然执行了,不显示自己的内容。可能是window显示出问题了
查看iOS13下UIWindow的定义,有这么一条
// If nil, window will not appear on any screen.
// changing the UIWindowScene may be an expensive operation and should not be done in performance-sensitive code
@property(nullable, nonatomic, weak) UIWindowScene *windowScene API_AVAILABLE(ios(13.0));
如果UIWindow的属性windowScene为nil,那么这个UIWindow则不会显示在任何屏幕上。
网友评论