默认情况下,FBLoginView 显示“登录”或“注销”,无论用户是否通过身份验证;
如果用户通过身份验证,我想隐藏 FBLoginView。我怎样才能做到这一点?如何检查用户是否已通过身份验证?
谢谢
默认情况下,FBLoginView 显示“登录”或“注销”,无论用户是否通过身份验证;
如果用户通过身份验证,我想隐藏 FBLoginView。我怎样才能做到这一点?如何检查用户是否已通过身份验证?
谢谢
编辑:在移动框架之前,您应该尝试执行以下任一操作:
loginview.hidden = YES;
或者
[loginview setHidden:YES];
使用 HelloFacebookSample,您可以简单地将 FBLoginView 框架移出屏幕。如果用户从登录更改为注销(反之亦然),委托方法将触发。
- (void)loginViewShowingLoggedInUser:(FBLoginView *)loginView {
// first get the buttons set for login mode
NSLog(@"FB logged in - token expiration: %@",[[FBSession activeSession] accessTokenData].expirationDate);
//User logged in. Move FBLoginView off the screen
loginview.frame = CGRectOffset(loginview.frame, 5, -100);
self.buttonPostPhoto.enabled = YES;
self.buttonPostStatus.enabled = YES;
self.buttonPickFriends.enabled = YES;
self.buttonPickPlace.enabled = YES;
// "Post Status" available when logged on and potentially when logged off. Differentiate in the label.
[self.buttonPostStatus setTitle:@"Post Status Update (Logged On)" forState:self.buttonPostStatus.state];
}
- (void)loginViewShowingLoggedOutUser:(FBLoginView *)loginView {
//User logged off. Move FBLoginView back within view
loginview.frame = CGRectOffset(loginview.frame, 5, 5); // test to see if we can use the share dialog built into the Facebook application
FBShareDialogParams *p = [[FBShareDialogParams alloc] init];
p.link = [NSURL URLWithString:@"http://developers.facebook.com/ios"];
#ifdef DEBUG
[FBSettings enableBetaFeatures:FBBetaFeaturesShareDialog];
#endif
BOOL canShareFB = [FBDialogs canPresentShareDialogWithParams:p];
BOOL canShareiOS6 = [FBDialogs canPresentOSIntegratedShareDialogWithSession:nil];
self.buttonPostStatus.enabled = canShareFB || canShareiOS6;
self.buttonPostPhoto.enabled = NO;
self.buttonPickFriends.enabled = NO;
self.buttonPickPlace.enabled = NO;
// "Post Status" available when logged on and potentially when logged off. Differentiate in the label.
[self.buttonPostStatus setTitle:@"Post Status Update (Logged Off)" forState:self.buttonPostStatus.state];
self.profilePic.profileID = nil;
self.labelFirstName.text = nil;
self.loggedInUser = nil;
}
在此示例中,您必须FBLoginView *loginview
在头文件中声明。