ios - 快速从 FIREBASE_REF block 内关闭 vc Controller

标签 ios swift firebase

如果用户已存在于 firebase 中,我只是在关闭 createuser vc 并返回到之前的初始 vc 方面寻求帮助。

我目前有:

// Attempt to create a new user.  (authData = dictionary).
        FIREBASE_REF.createUser(email, password: password, withValueCompletionBlock: { (error, authData) in

// If there was no error then
            if error == nil {
// Authorise the new user into the application.  (authData = object).
                FIREBASE_REF.authUser(email, password: password, withCompletionBlock: { ( error, authData) in

                    if error == nil {
// Store the user id into the device.
                        NSUserDefaults.standardUserDefaults().setValue(authData.uid, forKey: "uid")
// Stop the activity indicator.
                        self.activityInd.stopAnimating()
// Close the create user screen.
                        self.dismissViewControllerAnimated(true, completion: nil)
                    }
                    else
                    {
// Stop the activity indicator.
                        self.activityInd.stopAnimating()

                        print(error)

                   }
                })
            }
            else

// USER ACCOUNT ALREADY EXISTS \\
            {
// Stop the activity indicator.
                self.activityInd.stopAnimating()

// Display an error message.
                let alertController = UIAlertController(title: "USER DUPLICATION ERROR", message:
                    "user account already exists, login as normal", preferredStyle: UIAlertControllerStyle.Alert)
                alertController.addAction(UIAlertAction(title: "Dismiss", style: UIAlertActionStyle.Default,handler: nil))
                self.presentViewController(alertController, animated: true, completion: nil)

// Close the create user screen.
                self.dismissViewControllerAnimated(true, completion: nil)

            }
      })

当用户创建一个新帐户时,self.dismissViewController 工作得很好,并返回到初始 vc,然后加载主页。但是,当已有用户时, self.dismissViewController 不会执行任何操作。如果有人能对此有所了解,我们将不胜感激。

此外,如果有人可以建议如何确保警报消息保留在屏幕上,直到用户在关闭 vc 之前选择关闭,这也会有所帮助。

谢谢

最佳答案

问题已解决,如果有人感兴趣的话,我是如何解决这个问题的:

// USER ACCOUNT ALREADY EXISTS \\
            {
// Stop the activity indicator.
                self.activityInd.stopAnimating()

// Display an error message.
                let refreshAlert = UIAlertController(title: "USER DUPLICATION ERROR", message: "user account already exists, login as normal.", preferredStyle: UIAlertControllerStyle.Alert)

                refreshAlert.addAction(UIAlertAction(title: "Dismiss", style: .Default, handler: { (action: UIAlertAction!) in
// Close the create user screen.
                    self.dismissViewControllerAnimated(true, completion: nil)
                }))

                self.presentViewController(refreshAlert, animated: true, completion: nil)
            }
      })

关于ios - 快速从 FIREBASE_REF block 内关闭 vc Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36236380/

相关文章:

ios - 分支深层链接未打开应用程序

iphone - 如何对 iOS 应用程序使用的服务器进行负载测试?

ios - ( swift )初始 View Controller 调用 TableView Controller 而不点击任何按钮

ios - 如何通过在 Spritekit 中触摸隐藏的 SKSpriteNode 来检测它们?

xcode - 对象库 Xcode 6 中没有项目

ios - TableController不显示来自Core-data的数据

firebase - 如何查看 Firebase 通知发送报告?

ios - Swift 3 在检索数据时在 firebase 中获得零值

iphone - 我想通过用户名在 firebase 中搜索

ios - Objective-C 常量 : Xcode build failure for simulator while success in iPhone