我想在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()
答案 0 :(得分:3)
由于某些应用程序的滥用,Facebook仅仅通过忽略文本就明确禁用了预填充选项。
“您不得预先填写与 以下产品,除非用户手动生成内容 工作流中的更早部分:流故事(用于以下内容的user_message参数 Facebook.streamPublish和FB.Connect.streamPublish以及消息 stream.publish的参数),照片(标题),视频(描述), 注释(标题和内容),链接(注释)和Jabber / XMPP。”
更多信息here。
答案 1 :(得分:1)
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")
}
}
答案 2 :(得分:0)
尝试一下:
let sharePhoto = FBSDKSharePhoto()
photo.image = photo
photo.caption = "you title"
let content = FBSDKShareMediaContent()
content.media = [photo];