【发布时间】:2016-05-06 17:07:21
【问题描述】:
在开始之前,我已经搜索了 Stackoverflow 以了解如何执行此操作,并且我看到了很多相关的帖子,但没有一个对我有用,我不知道为什么。
所以基本上我有一个 loginViewController,在其中,我有一个调用 GoogleSignIn 的方法:
- (void)googleTap:(id)sender
{
[[GIDSignIn sharedInstance] signIn];
}
现在设置 GoogleSignIn 的方式,登录调用的结果在 AppDelegate.m 中处理
- (void)signIn:(GIDSignIn *)signIn
didSignInForUser:(GIDGoogleUser *)user
withError:(NSError *)error {
// Perform any operations on signed in user here.
if (!error) {
NSString *userId = user.userID; // For client-side use only!
NSString *idToken = user.authentication.idToken; // Safe to send to the server
NSString *name = user.profile.name;
NSString *email = user.profile.email;
NSLog(@"Name: %@, User: %@, Token: %@, Email: %@",name, userId, idToken, email);
// ...
}
}
在这个 AppDelegate 方法中,我想从我的 loginViewController 中调用一个方法:
-(void)onSuccessfulLogin{
NSLog(@"On Successful Login");
[self.navigationController pushViewController:[collectionViewController new] animated:YES];
}
我尝试了这些答案:Calling UIViewController method from app delegate
want to call ViewController's method from appdelegate
NSLog 被调用,但新的 ViewController 从未被推送...为什么会这样,我怎样才能让它工作?
【问题讨论】:
-
self.navigationController 为零吗?
-
从 google 下载 google sdk 并解压,您将看到示例代码,希望它能解决您的问题。
标签: ios objective-c uiviewcontroller appdelegate