Swift UITabBarController的登录屏幕缺少导航链接

Swift UITabBarController的登录屏幕缺少导航链接,swift,uinavigationcontroller,uitabbarcontroller,uitabbar,Swift,Uinavigationcontroller,Uitabbarcontroller,Uitabbar,我的登录屏幕嵌入在导航控制器中。 一旦用户使用正确的凭据登录,我想将用户推送到UITabBarController。我可以做到这一点,但当我通过单击选项卡转到不同的视图时,各个视图都不会显示任何导航按钮 应用内代理,登录成功后,我将使用以下代码: let myStoryBoard:UIStoryboard = UIStoryboard(name:"Main", bundle:nil) let protectedPage = myStoryBoard.instantiateViewControl

我的登录屏幕嵌入在导航控制器中。 一旦用户使用正确的凭据登录,我想将用户推送到UITabBarController。我可以做到这一点,但当我通过单击选项卡转到不同的视图时,各个视图都不会显示任何导航按钮

应用内代理,登录成功后,我将使用以下代码:

let myStoryBoard:UIStoryboard = UIStoryboard(name:"Main", bundle:nil)

let protectedPage = myStoryBoard.instantiateViewController(withIdentifier: "MainView") as! UITabBarController

let protectedPageNav = UINavigationController(rootViewController: protectedPage)

self.window?.rootViewController = protectedPageNav
我怎样才能解决这个问题


根据苹果的文档说明,您最好将UIAbbarController指定为UIWindow的根目录

所以,改变你的代码

let myStoryBoard:UIStoryboard = UIStoryboard(name:"Main", bundle:nil)

let protectedPage = myStoryBoard.instantiateViewController(withIdentifier: "MainView") as! UITabBarController


//change UIViewAnimationOptions enum value and you will get some animation
UIView.transition(with: self.window!, duration: 0.34, options: UIViewAnimationOptions.transitionCrossDissolve, animations: {
            self.window?.rootViewController = protectedPage
        }, completion: {competion in

        })

令人惊叹的。非常感谢!!