从ViewController中的符号转换到UITabBarController

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

所以我尝试在登录成功后从我的登录控制器转换到我的tabbarcontroller。

当我输入登录详细信息并按下登录按钮时,我被重定向到Appdelegate页面,并显示SIGABRT信号错误。

我尝试在我的viewcontroller中使用此代码:

            let mainPage = self.storyboard?.instantiateViewController(withIdentifier: "CustomViewController") as! CustomViewController
            self.present(mainPage, animated: true, completion: nil)

Screenshot of problem(1) Screenshot of problem(2)

swift xcode uiviewcontroller uitabbarcontroller swift4
2个回答
0
投票

CustomViewController中有什么?如果您将该实例直接实例化为ViewController而不是UiTabBarViewController,我认为您需要手动为每个选项卡添加Sub ViewControllers。但是如果不查看CustomViewController中的内容,很难确定。


0
投票

您是否尝试将应用程序的rootViewController设置为UITabBarController实例?

例如,这会将应用程序的rootViewController设置为标签栏控制器:

let mainPage = self.storyboard?.instantiateViewController(withIdentifier: "CustomViewController") as! CustomViewController

UIApplication.shared.keyWindow?.rootViewController = mainPage
© www.soinside.com 2019 - 2024. All rights reserved.