我创建的TableViewcontroller.xib应该是初始控制器

问题描述 投票:0回答:2

我已经通过xib创建了TableViewController而不是故事板。我有视图控制器默认加载。现在我希望TableViewController作为根控制器。提前致谢。

swift uitableview nib rootviewcontroller
2个回答
0
投票

你可以这样做。

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {        
    window = UIWindow(frame: UIScreen.main.bounds)  
    let navigationController: UINavigationController = UINavigationController(rootViewController: YourViewController()) //where YourViewController is name of viewController which you want to use as rootViewController
    self.window?.rootViewController = navigationController
    self.window?.makeKeyAndVisible()
    return true
}

1
投票

1首先在你想要加载的viewController中注册你的xib。通过register.nibLod 2然后在AppDelegate中 - didFinish方法使你的特定viewController成为rootviewcontroller。

© www.soinside.com 2019 - 2024. All rights reserved.