我的登录屏幕嵌入在导航控制器中。 一旦用户使用正确的凭据登录,我想将用户推送到UITabBarController。我可以这样做,但是当我通过单击选项卡转到不同的视图时,各个视图都没有出现任何导航按钮。
在app delegate中,一旦登录成功,我将使用以下代码:
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
我该如何解决这个问题?
答案 0 :(得分:0)
根据Apple文档声明,您最好将UITabBarController指定为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
})