简体   繁体   English

将我的应用中的图像分享到Facebook

[英]Share an image from my app to facebook

I have a movie quiz app, and I want users to share the movie scene image that they are stuck on to Facebook so they can ask their friends for help. 我有一个电影测验应用程序,我希望用户共享粘贴在Facebook上的电影场景图像,以便他们可以向朋友寻求帮助。

With Facebook's recent changes I am struggling to figure out how to post the image that the user is up to. 随着Facebook的最新变化,我正在努力找出如何发布用户的图片。

All the movie scene images are stored in the app so there is no URL. 所有电影场景图像都存储在应用程序中,因此没有URL。

I am trying to get the image from my array like this: 我试图像这样从我的数组中获取图像:

FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.imageURL = [NSURL fileURLWithPathComponents:[[mainInfoArray objectAtIndex:index] objectForKey:PHONE_IMAGE]];

but it does not work. 但它不起作用。 Any ideas please to get this to work? 有什么想法可以使它起作用吗? Thank You 谢谢

First, you create the content, then you create a share-button with that content. 首先,您创建内容,然后使用该内容创建一个共享按钮。

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

FBSDKShareButton *button = [[FBSDKShareButton alloc] init];
button.shareContent = content;  
[self.view addSubview:button];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM