1

尝试通过 FBSDKShareLinkContent 共享本地图像但没有成功。

我的示例代码是:

 let content: FBSDKShareLinkContent = FBSDKShareLinkContent()
    content.contentTitle = "test share"
    content.contentURL = NSURL(string: "http://example.com")
    let path = NSBundle.mainBundle().pathForResource("testImage", ofType: "png")
    content.imageURL = NSURL(string: path!)
    let shareDialog = FBSDKShareDialog()
    shareDialog.mode = FBSDKShareDialogMode.Native
    shareDialog.shareContent = content
    shareDialog.fromViewController = self
    shareDialog.show()
4

1 回答 1

0

对于共享图像,您需要使用FBSDKSharePhotoContent. 检查Objective C中的以下代码

- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
  UIImage *image = info[UIImagePickerControllerOriginalImage];

  FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
  photo.image = image;
  photo.userGenerated = YES;
  FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init];
  content.photos = @[photo];
  ...
}

参考:https ://developers.facebook.com/docs/sharing/ios

于 2015-10-06T11:40:56.310 回答