图片不会通过iOS 6应用在Facebook上发布

时间:2013-07-30 02:57:27

标签: facebook image ios6 share

我试图通过我的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徽标代替它。我不明白这里出了什么问题。有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

这是因为addURL:iOS会自动添加网址的Safari预览,因为它还没有加载,它会显示Safari预览,就像这个

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