【发布时间】:2020-05-18 02:13:50
【问题描述】:
我首先使用 GoogleSignIn SDK 作为登录短语。然后,我使用以下代码重定向到我的应用程序的主页。
self.present(tabController, animated: true, completion: nil)
这是我的应用程序的结构(我使用故事板):
TabBarController
- NavigationBarController(主页):视图控制器
- NavigationBarController(功能 1):视图控制器
- NavigationBarController(功能 2):视图控制器
- NavigationBarController(配置文件):视图控制器
现在我已经登录,我想将数据从谷歌传递到我的个人资料根视图控制器。然而,我不知道该怎么做。
这是我当前的代码,我已经输入了 func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!):
let tabController: UITabBarController = self.storyboard?.instantiateViewController(withIdentifier: "homepageVC") as! UITabBarController
let navController: UINavigationController = self.storyboard?.instantiateViewController(withIdentifier: "homepageVC2") as! UINavigationController
let vc = navController.viewControllers[0] as! ViewController
tabController.modalPresentationStyle = .fullScreen
vc.name = fullName
self.present(tabController, animated: true, completion: nil)
** 其中 fullName 是我的 LoginViewController 中的全局变量,其中包含 user.fullName(来自 google)。
但是因为,它不起作用。我希望有人可以帮助我解决这个问题。非常感谢。
【问题讨论】:
-
这是 iOS 中的一个大话题(就像在大多数框架中一样)。对于只有一个用户并且每个人都需要知道的用户数据,请使用单例。 stackoverflow.com/a/26743597/294949
标签: ios swift uinavigationcontroller uitabbarcontroller viewcontroller