栏项目不显示我何时以编程方式使用segue

发布于 2025-01-25 17:50:43 字数 874 浏览 4 评论 0原文

我正在构建一个具有只有现有用户才能登录到的主VC的应用程序。主页是初始VC,因此我将导航栏嵌入到它。当我第一次打开应用程序时,我可以看到栏项目,但是当我登录并再次登录时,我看不到bar项目,有人知道为什么吗?我应该添加一些代码吗?还是更改一些定义?

我以这样的方式编程使用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,但现在看不到条件(图3)。

链接到应用程序图片

I’m building an app which has a main vc that only existing user can log in to. The main page is the initial vc so I embed in the navigation bar to it. When I open the app in the first time I can see the bar items, but when I sign out, and log in again I can’t see the bar items, someone know why? Should I add some code? or maybe change some definitions?

I’m using segue programmatically like this:

  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...
          })

In the simulator it starts with the main vc then I sign out (pic 1), then I log in (pic 2) and get back to the main vc but now I can’t see the bar items (pic 3).

link to the app pictures

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

灵芸 2025-02-01 17:50:44

您必须在NavigationController私有VAR句柄中介绍您的主要风险

投资:AuthstatedIdIdChangelisTenerHandle?

hander = auth.auth()。
如果用户== 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...
      })

you must present your main vc in navigationcontroller

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
                  {
                      let navVc = UINavigationController(rootViewController: vc)
                      
                      self.present(navVc, animated: true, completion: nil)
                  }
            
        }else{
            //keep going with the code...
      })
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文