Swift 登录屏幕SWIF5后返回上一个viewController

Swift 登录屏幕SWIF5后返回上一个viewController,swift,viewcontroller,Swift,Viewcontroller,用户必须登录才能访问我的应用程序上的配置文件信息。当他点击profile页面时,如果用户没有登录,我会将他重定向到登录屏幕。如果他能正确登录,我必须将他重定向回个人资料页面。我该怎么做 如果用户未登录: 用户成功登录后: 我找到了从以下位置获取上一个viewController的一些扩展: 当用户单击登录按钮时,请尝试执行以下操作: @IBAction func girisYapButtonClicked(_ sender: Any) { if emailText.text != &

用户必须登录才能访问我的应用程序上的配置文件信息。当他点击profile页面时,如果用户没有登录,我会将他重定向到登录屏幕。如果他能正确登录,我必须将他重定向回个人资料页面。我该怎么做

如果用户未登录:

用户成功登录后:

我找到了从以下位置获取上一个viewController的一些扩展:

当用户单击登录按钮时,请尝试执行以下操作:

@IBAction func girisYapButtonClicked(_ sender: Any) {
    if emailText.text != "" && emailText.text != "" {
        Auth.auth().signIn(withEmail: emailText.text!, password: passwordText.text!) { (userData, error) in
            
        if error != nil{
            self.makeAllert(title: "Uyarı", message: error!.localizedDescription)
            
        }else if self.navigationController?.viewControllers.previous is profileViewController{
            self.navigationController?.popToViewController(loginViewController(), animated: true)
            
        }else{
            print(self.navigationController?.viewControllers.previous!)
        }
      
    }
    }else{
     makeAllert(title: "Uyarı", message: "Eksik bilgi girdiniz")
        
    }
你可以用

navigationController?.popViewController(animated: true)

在NavigationController中返回导航。

如何将用户重定向到登录屏幕?你是显示登录屏幕还是按它?我正在按。-如果Auth.Auth.currentUser==nil{let vc=storyboard?.InstanceEviewController的标识符:loginScreen self.navigationController?.pushViewControllervc!,动画:true