对于您的情况,首先您需要为您创建一个类,UITabBarController这将确认UITabBarController不是UIViewController:
class TabBarConroller: UITabBarController {
TabBarConroller是你的新.swift文件。现在转到您的故事板并单击您的TabBarController并单击 Identity Inspector 并将这个新创建的类分配给它。
接下来,如果用户使用以下代码成功进行身份验证,您需要启动该类:
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let tabbarVC = storyboard.instantiateViewController(withIdentifier: "TabbarIdentifier") as! UITabbarController
self.present(tabbarVC, animated: false, completion: nil)
Storyboard ID您还需要从 Identity Inspector分配一件事,即TabbarIdentifier.
所以你的代码看起来像:
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!,
withError error: Error!) {
if let error = error {
print("\(error.localizedDescription)")
} else {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let tabbarVC = storyboard.instantiateViewController(withIdentifier: "TabbarIdentifier") as! UITabbarController
self.present(tabbarVC, animated: false, completion: nil)
}
}