【发布时间】:2020-05-13 21:15:58
【问题描述】:
我刚刚开始了一个新的 iOS 项目。我使用 xcode 11 和 iOS 13 创建了项目。当我创建项目时,我发现为了设置我们自己的 rootController,我们必须使用 sceneDelegate 而不是 AppDelegate。我想问是否有可能使用在 AppDelegate 中设置 rootControllers 的旧方法而不是使用 sceneDelegate。
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window : UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let loginController: HomeViewController = HomeViewController(nibName: "HomeViewController", bundle: nil)
// let navController: UINavigationController = UINavigationController(rootViewController: loginController)
self.window?.rootViewController = loginController
self.window?.makeKeyAndVisible()
// Override point for customization after application launch.
return true
}
}
【问题讨论】:
-
您的
HomeViewController或Main.Stroyboard中是否有单独的笔尖文件? -
@KeshuR。它是 homeviewcontroller 的一个单独的 nib。
标签: ios swift uiviewcontroller ios13 xcode11