4

我正在尝试使用 FLoginView 为 facebook 创建登录按钮。以下是我编写的代码。

- (void)viewDidLoad
{
[super viewDidLoad];

if(!loginview)
    loginview = [[FBLoginView alloc] initWithPermissions:[NSArray arrayWithObject:@"publish_actions, user_photos,status_update"]]; // Whatever permissions you need

loginview.frame = self.view.bounds; //whatever you want

loginview.delegate = self;

[self.view addSubview:loginview];
// Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

- (void)loginViewShowingLoggedInUser:(FBLoginView *)loginView {

NSLog(@"Logged In");

}

- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView
                        user:(id<FBGraphUser>)user {
NSLog(@"user Id %@",user.id);

}
- (void)loginViewShowingLoggedOutUser:(FBLoginView *)loginView {
// Called after logout
NSLog(@"Logged out");
}

但它没有显示登录按钮。我的代码有什么问题。在控制台中我得到“注销”。

4

2 回答 2

6

我添加了 FacebookSDKResources.bundle,但仍然在 xcode 输出窗格中出现错误“Unknown class FBLoginView in interface builder”。

为了解决这个问题,我在 didFinishLaunchingWithOptions 中添加了以下行:

[FBLoginView class];

这在https://developers.facebook.com/ios/login-ui-control/中有解释

于 2013-04-30T21:37:08.927 回答
4

正如上面@rajath 所指出的,解决方案是将 FacebookSDKResources.bundle 添加到您的项目中。

于 2013-04-24T02:21:54.960 回答