1

我正在尝试通过我的 iOS6 应用在 Facebook 上发布一张带有小描述的图片。我为此使用 SLComposeViewController:

   if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {            

        SLComposeViewController *mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

        NSString *shareText = @"This is my art using MyApp";
        [mySLComposerSheet setInitialText:shareText];

        **[mySLComposerSheet addImage:self.mainImage.image];**

        [mySLComposerSheet addURL:[NSURL URLWithString:@"https://itunes.apple.com/in/app/myApp/id665759410?mt=8"]];

        [mySLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result) {

            switch (result) {
                case SLComposeViewControllerResultCancelled: {
                    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Error" message:@"Could not post on your wall" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles: nil];
                    [alert show];
                    NSLog(@"Post Canceled");
                    break;
                }
                case SLComposeViewControllerResultDone:
                {
                    NSLog(@"Post Sucessful");
                    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Success" message:@"Posted succesfully on your wall" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles: nil];
                    [alert show];
                    break;
                }
                default:
                    break;
            }
        }];

        [self presentViewController:mySLComposerSheet animated:YES completion:nil];
    }

这是目前我用于发布到 Facebook 的代码。但这并没有在发布期间显示图像,而是有一个空白的 Safari 徽标代替它。我不明白这里出了什么问题。有人可以帮忙吗?

4

1 回答 1

0

这是因为 addURL: iOS 自动添加了 url 的 Safari 预览,由于还没有加载,所以显示的是 safari 预览,就像这个一样

https://stackoverflow.com/a/14265411/474330

于 2013-07-30T03:02:36.253 回答