performSegue 在检查用户是否经过身份验证时无法使用 FireBase Swift 3/4 [英] performSegue not working FireBase while checking the user is authenticated Swift 3/4

查看:23
本文介绍了performSegue 在检查用户是否经过身份验证时无法使用 FireBase Swift 3/4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚完成了一个关于 firebase 与社交登录混合的 letbuildthatapp 教程视频.

I just finish a tutorial video of letsbuildthatapp about firebase mixed with social login.

如果用户已通过身份验证,我目前正在尝试执行 segue.

I currently trying to perform a segue if the user is already authenticated.

我在我的 if 和 just after 我用一个我知道工作的 segue 打印了一些东西,因为我正在使用它进行测试.

I print something in my if and just after I performSegue with a segue who I know work because I'm using it for a test.

这是我的代码

func verifDejaConnecter() {
    if Auth.auth().currentUser?.uid != nil {
        performSegue(withIdentifier: "segueAccueilToPres", sender: nil)
        print("test")
    } else {
        return
    }
}

mySegue 已创建并运行,但此处未添加任何内容.

mySegue is created and works but nothing append here.

在控制台中,我可以看到 if 中的打印结果...但没有任何变化

In the console I can see the test resulting from the print in the if ... but nothing is mooving

推荐答案

试试这个:

func verifDejaConnecter() {
  if Auth.auth().currentUser?.uid != nil {
    DispatchQueue.main.async {
      self.performSegue(withIdentifier: "segueAccueilToPres", sender: self)
        print("test")
    }
  } else {
    return
  }
}

这篇关于performSegue 在检查用户是否经过身份验证时无法使用 FireBase Swift 3/4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆