Swift 从登录ViewController转换为UITabBarController

Swift 从登录ViewController转换为UITabBarController,swift,xcode,uiviewcontroller,uitabbarcontroller,swift4,Swift,Xcode,Uiviewcontroller,Uitabbarcontroller,Swift4,因此,在成功登录后,我尝试从登录viewcontroller过渡到tabbarcontroller 当我输入登录详细信息并按下登录按钮时,我会被重定向到Appdelegate页面,并显示SIGABRT错误信号 我尝试在我的viewcontroller中使用以下代码: let mainPage = self.storyboard?.instantiateViewController(withIdentifier: "CustomViewController") as! Cu

因此,在成功登录后,我尝试从登录viewcontroller过渡到tabbarcontroller

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

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

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

UIApplication.shared.keyWindow?.rootViewController = mainPage

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

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

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

UIApplication.shared.keyWindow?.rootViewController = mainPage

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

CustomViewController中的内容是什么?如果直接将其实例化为ViewController而不是UiTabBarViewController,我认为您需要手动为每个选项卡添加子ViewController。但如果不查看CustomViewController中的内容,就很难确定。哦,我刚刚注意到了这一点。非常感谢。现在一切都好了:)好的,我将添加这个作为答案,这样您就可以接受它,这将结束这个问题,谢谢!