我这样做了:" SecondViewController"是我想去的视图控制器:
func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "idSegueContent" {
secondViewController = segue.destinationViewController as! SecondViewController //Error is here
}
}
public func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) {
if (error) != nil {
print(error)
}
else {
performSegue(withIdentifier: "idSegueContent", sender: self)
}
}
func sign(_ signIn: GIDSignIn!, didDisconnectWith user: GIDGoogleUser!, withError error: Error!) {
if let err = error {
print(error)
}
SecondViewController.dismissViewControllerAnimated(true, completion: nil)
//Error is here too
}
我正在尝试使用Gmail帐户登录,并在用户登录时在其他页面中显示用户信息。
答案 0 :(得分:-1)
您可以添加此代码,以帮助您导航到其他ViewController
:
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) {
if error != nil
{
print(error ?? "google error")
return
}
let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let newViewController = storyBoard.instantiateViewController(withIdentifier: "navigation") as! NavigationController
self.present(newViewController, animated: false, completion: nil)
// lblUserName.text = user.profile.email
}