【发布时间】:2015-04-28 06:15:02
【问题描述】:
我想在 Facebook 上分享应用程序中的照片和一些文字。我使用SLComposeViewController 类进行分享。
我的问题是,当我点击 Facebook 按钮时,会出现一个对话框,其中包含我要发布的图像,但默认文本在模拟器中没有出现在设备中,它工作得非常好。此代码在模拟器和设备中都适用于 Twitter。为了更清楚,我添加了代码和图像
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
{
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result)
{
if (result == SLComposeViewControllerResultCancelled)
{
NSLog(@"Cancelled");
} else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Congratulations!" message:@"Photo is posted to facebook Wall." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[alert show];
}
[controller dismissViewControllerAnimated:YES completion:Nil];
};
controller.completionHandler =myBlock;
str=[NSString stringWithFormat:@"Text to share"];
[controller setInitialText:str];
[controller addImage:savedImage];
[self presentViewController:controller animated:YES completion:Nil];
}
【问题讨论】:
-
检查 str 是否有值?
-
@vijeesh - 我已经验证它有一个值
-
问题出在 Facebook 的某个地方,在他们最后一次更新之后,SLComposeViewController 坏了一半。我所有的应用程序现在都显示空的 SLComposeViewController。
标签: ios objective-c iphone facebook ios8.3