[英]How to share image with text in Facebook SDK in swift
我想在 facebook 上分享一个带有图片和文字的帖子。 我正在使用 Facebook SDK 并且可以共享图像,现在我想与此图像共享文本。 我怎么能?
这是分享图片的源代码,
let photo:FBSDKSharePhoto = FBSDKSharePhoto()
var message:String?
let imageName:String = "Star.png"
photo.image = UIImage(named: imageName)
photo.isUserGenerated = true
let content = FBSDKSharePhotoContent()
content.photos = [photo];
let dialog = FBSDKShareDialog()
dialog.fromViewController = self
dialog.shareContent = content
dialog.mode = .native
dialog.show()
由于某些应用程序的滥用,Facebook 通过简单地忽略它来明确禁用文本的预填充选项。
“您不得预先填写与以下产品关联的任何字段,除非用户在工作流程的早期手动生成内容:流故事(Facebook.streamPublish 和 FB.Connect.streamPublish 的 user_message 参数,以及流的消息参数.publish)、照片(标题)、视频(说明)、注释(标题和内容)、链接(评论)和 Jabber/XMPP。”
更多信息在这里。
Facebook 不允许用户添加带有图像的文本。
整合facebookshare sdk
@IBAction func facebookBtn(sender: AnyObject) {
let shareImage = SharePhoto()
shareImage.image = imageView.image //Image from your imageview
shareImage.isUserGenerated = true
let content = SharePhotoContent()
content.photos = [shareImage]
let sharedDialoge = ShareDialog()
sharedDialoge.shareContent = content
sharedDialoge.fromViewController = self
sharedDialoge.mode = .automatic
if(sharedDialoge.canShow)
{
sharedDialoge.show()
}
else
{
print("Install Facebook client app to share image")
}
}
尝试这个 :
let sharePhoto = FBSDKSharePhoto()
photo.image = photo
photo.caption = "you title"
let content = FBSDKShareMediaContent()
content.media = [photo];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.