我的导航 Controller 中有两个 VC - SignInVC
和 SignUpVC
。
两者都包含自定义 Google 登录按钮。
当应用程序启动时,SignInVC 首先出现。当我按下 SignUpVC 并按以下方式返回 SignInVC 时
_ = self.navigationController?.popViewController(animated: true)
我无法使用按钮登录,因为以下原因
Warning: Attempt to present SFSafariViewController: 0x157d47140 on TestProject.SignUpViewController: 0x157d2f3b0 whose view is not in the window hierarchy
控制台中显示错误。
值得一提的是,我还有 FB 登录按钮,它适用于两个 View Controller 。此外,无论在导航中来回,SignUpVC 中的按钮始终有效
这是 Google 登录特有的内容吗?
如何解决?
最佳答案
这是因为在 ViewDidLoad() 方法中设置了委托(delegate),当用户返回导航堆栈中的上一个 Controller 时不会调用该方法。
这个
override func viewWillAppear(_ animated: Bool) {
GIDSignIn.sharedInstance().uiDelegate = self
GoogleManager.shared.delegate = self
}
解决了问题。
关于ios - 弹出 VC 时 Google 登录按钮不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41895578/