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