嗨,我已经为 iOS 6 应用程序集成了 Facebook SDK。Facebook 身份验证和共享工作完美,但没有规定关闭 FB Dialogue box.ie。当 FB 对话框打开时,只有在身份验证成功后才会关闭。没有关闭或导航返回的规定。如何制作关闭按钮。我正在使用的代码片段如下所示。提前致谢。
-(NSDictionary *)shareFacebook
{
NSDictionary *userInfo;
if (FBSession.activeSession.isOpen)
{
if (FBSession.activeSession.isOpen)
{
[self.closeButton setHidden:NO];
[FBRequestConnection startForMeWithCompletionHandler:^(FBRequestConnection *connection, id<FBGraphUser> user, NSError *error) {
NSUserDefaults *standardUserDefaults=[NSUserDefaults standardUserDefaults];
[standardUserDefaults setObject:user forKey:@"fbUserInfo"];
[self.manager authenticateUserUsingFB:[user objectForKey:@"email"]];
}];
}
}
else{
NSLog(@"fb session not active.");
[self openSessionWithAllowLoginUI:YES];
}
return userInfo;
}
- (void)openSessionWithAllowLoginUI:(BOOL)allowLoginUI {
NSArray *permissions = [[NSArray alloc] initWithObjects:
@"user_photos",
@"publish_actions",
@"read_stream",
@"friends_photos",
@"email" ,nil];
[FBSession setActiveSession:[[FBSession alloc] initWithPermissions:permissions]];
[[FBSession activeSession] openWithBehavior:FBSessionLoginBehaviorForcingWebView
completionHandler:^(FBSession *session,
FBSessionState state,
NSError *error) {
NSLog(@" state=%d",state);
if(FBSessionStateOpen)
{
[self shareFacebook];
}
}];
}