我有视图控制器添加了facebook登录按钮。我上课:FacebookAuth方法:
- (void) performAuth {
[FBSession openActiveSessionWithReadPermissions:nil
allowLoginUI:YES
completionHandler:
^(FBSession *session,
FBSessionState state, NSError *error) {
[self fbSessionStateChanged:session state:state error:error];
}];
}
在我的Facebook视图控制器中,我有IBAction:
- (IBAction)performFBLogin:(id)sender {
FacebookAuth *fbAuth = [[FacebookAuth alloc] init];
[fbAuth performAuth];
[self.navigationController popToRootViewControllerAnimated:YES];
}
问题是:如何在[self.navigationController popToRootViewControllerAnimated:YES];
执行后致电performAuth
。
根据官方指南,AppDelegate中有一个回调:
// During the Facebook login flow, your app passes control to the Facebook iOS app or Facebook in a mobile browser.
// After authentication, your app will be called back with the session information.
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation
{
return [FBAppCall handleOpenURL:url sourceApplication:sourceApplication];
}
提前致谢。
答案 0 :(得分:0)
我不确定,但你有没有尝试过这种方式,
- (void) performAuth {
[FBSession openActiveSessionWithReadPermissions:nil
allowLoginUI:YES
completionHandler:
^(FBSession *session,
FBSessionState state, NSError *error) {
[self fbSessionStateChanged:session state:state error:error];
[self.navigationController popToRootViewControllerAnimated:YES];
}];
}