当我以编程方式使用segue时,栏项不显示



我正在构建一个应用程序,其中有一个主要的vc,只有现有用户可以登录到。主页是最初的vc,所以我嵌入在导航栏到它。当我第一次打开应用程序时,我可以看到栏项,但当我退出并再次登录时,我看不到栏项有人知道为什么吗?我应该添加一些代码吗?或者改变一些定义?

我用编程方式使用segue,像这样:

private var handle: AuthStateDidChangeListenerHandle?

handle = Auth.auth().addStateDidChangeListener({ (auth, user) in
if user == nil{

if let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "Home") as? MainVC
{
self.present(vc, animated: true, completion: nil)
}

}else{
//keep going with the code...
})

在模拟器中,它从主vc开始,然后我退出(pic 1),然后我登录(pic 2)并回到主vc,但现在我看不到栏项(pic 3)。

链接到应用程序图片

你必须在navigationcontroller

中显示你的主vcprivate var handle: authstateddchangelistenerhandle ?

handle = Auth.auth()。addStateDidChangeListener({(auth, user) in如果user == nil{

if let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "Home") as? MainVC
{
let navVc = UINavigationController(rootViewController: vc)

self.present(navVc, animated: true, completion: nil)
}

}else{
//keep going with the code...
})

最新更新