我正在使用以下代码在 facebook 上发布照片。
if ([FBDialogs canPresentShareDialogWithPhotos])
{
FBShareDialogPhotoParams *params = [[FBShareDialogPhotoParams alloc] init];
// Note that params.photos can be an array of images. In this example
// we only use a single image, wrapped in an array.
params.photos = @[imageDetails.chosenImage];
params.place=@"Abracadabra Snap! ios application";
[FBDialogs presentShareDialogWithPhotoParams:params
clientState:nil
handler:^(FBAppCall *call,
NSDictionary *results,
NSError *error) {
if (error) {
NSLog(@"Error: %@",
error.description);
} else {
NSLog(@"Success!");
}
}];
}
它向我展示了一个对话框,我在其中写了一些文本并单击发布,在我单击发布后,它上传了图像并返回到调用 Controller ,但既不返回错误也不返回成功,也不发布Facebook 上的图像。请帮忙解决这个问题
最佳答案
试试这个......在分享按钮......
- (IBAction)facebookPost:(id)sender
{
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
{
SLComposeViewController *mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[mySLComposerSheet setInitialText:@"ABC"];
[mySLComposerSheet addImage:[UIImage imageNamed:@"abc.png"]];
[mySLComposerSheet addURL:[NSURL URLWithString:@"google.com"]];
[mySLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result)
{
switch (result)
{
case SLComposeViewControllerResultCancelled:
{
NSLog(@"Post Canceled");
break;
}
case SLComposeViewControllerResultDone:
{
NSLog(@"Post Sucessful");
break;
}
default:
break;
}
}];
[self presentViewController:mySLComposerSheet animated:YES completion:nil];
}
}
关于ios - Facebook sdk 不从 ios 应用程序发布图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22963068/