尝试通过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()
答案 0 :(得分: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];
...
}