ios - Facebook 发帖

标签 ios facebook

这就是我所做的

但是什么也没发生。我是不是漏掉了一步?

这是我正在使用的代码

 if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) //check if Facebook Account is linked
    {
      mySLComposerSheet = [[SLComposeViewController alloc] init]; //initiate the Social Controller
        mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook]; //Tell him with what social plattform to use it, e.g. facebook or twitter
                [mySLComposerSheet setInitialText:[NSString stringWithFormat:@"Test",mySLComposerSheet.serviceType]]; //the message you want to post
       [mySLComposerSheet addImage:yourimage]; //an image you could post
        //for more instance methodes, go here:https://developer.apple.com/library/ios/#documentation/NetworkingInternet/Reference/SLComposeViewController_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40012205
        [self presentViewController:mySLComposerSheet animated:YES completion:nil];
    }
    [mySLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result) {
        NSString *output;
        switch (result) {
            case SLComposeViewControllerResultCancelled:
                output = @"Action Cancelled";
                break;
            case SLComposeViewControllerResultDone:
                output = @"Post Successfull";
                break;
            default:
                break;
        } //check if everything worked properly. Give out a message on the state.
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Facebook" message:output delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
        [alert show];
    }];

最佳答案

您的setInitialText 方法不正确。 如果您使用 stringWithFormat 发布 serviceType,则需要将其添加到带有“%@”的方法中,否则没有任何内容可以显示。

简而言之,只需更改:

[mySLComposerSheet setInitialText:[NSString stringWithFormat:@"Test",mySLComposerSheet.serviceType]];

到:

[mySLComposerSheet setInitialText:[NSString stringWithFormat:@"Test %@",mySLComposerSheet.serviceType]];

关于ios - Facebook 发帖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19061041/

相关文章:

ios - CoreData : error: (14) on device, 不在模拟器中

ios - 如何在 View 的图层颜色发生变化时制作不同的颜色外观

iphone - iOS Facebook 发布对话框无法在设备上正确呈现

javascript - Facebook 登录 Javascript SDK 自动登录(如果设置了 cookie)

facebook - 从 Facebook 的 Graph Search API 获取公开帖子

ios - www/res/screen/ios 中的 Cordova/Phonegap 飞溅是什么?

ios - Handoff 和 Universal Links 在 iOS 9 上失败

iphone - 用户点击谷歌地图 ios 时如何读取经度和纬度?

android - 如何在 Android 中使用 Facebook SDK 在 Facebook 上分享文本

php - Facebook 连接 'next' 错误