Fbconnect在ios处显示白色空白屏幕

时间:2012-04-07 09:41:28

标签: ios screen sharekit fbconnect

我需要ios app的facebook共享组件。我使用fbcoonect但它无法正常工作。登录屏幕后,当我使用fbdialog时,它会显示白屏。 sharekit示例也给出了相同的错误。照片共享有效但文本,链接共享在sharekit默认示例中不起作用。当您想要分享内容时,它会在登录对话框后显示白色空白屏幕。有什么想法吗?

1 个答案:

答案 0 :(得分:-1)

尝试使用此代码即可。别忘了在.plist和代码中添加APP_ID。

-(void)buttonPressed:(id)sender{
facebook = [[Facebook alloc] initWithAppId:@"YOUR_APP_ID" andDelegate:self];

 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
        if ([defaults objectForKey:@"FBAccessTokenKey"] && [defaults objectForKey:@"FBExpirationDateKey"]) {
            facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
            facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
        }
if (![facebook isSessionValid]) {
    [facebook authorize:nil];
}else{
[self postWall];
}
// Pre 4.2 support
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
    return [facebook handleOpenURL:url]; 
}
- (void)fbDidLogin {
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"];
    [defaults setObject:[facebook expirationDate] forKey:@"FBExpirationDateKey"];
    [defaults synchronize];
    [self postWall];
}
-(void)postWall{

    NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   @"https://developers.facebook.com/docs/reference/dialogs/",@"link",
                                   @"http://fbrell.com/f8.jpg",@"picture",
                                   @"Facebook Dialogs",@"name",
                                   @"Reference Documentation",@"caption",
                                   @"Using Dialogs to interact with users.",@"description",
                                   @"Facebook Dialogs are so easy!",@"message",
                                   nil];

    [[self facebook] dialog:@"feed" andParams:params andDelegate:self];

}