如何在Swift中使用Facebook SDK分享带有文本的图片

3

我希望在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()
3个回答

6
由于一些应用程序的滥用,Facebook已经明确禁用了预填选项,只需简单地忽略它。
“除非用户在工作流程中手动生成内容,否则不得预先填写与以下产品相关联的任何字段:流式故事(Facebook.streamPublish和FB.Connect.streamPublish的user_message参数,以及stream.publish的message参数),照片(标题),视频(说明),笔记(标题和内容),链接(注释)和Jabber / XMPP。”
更多信息请点击 这里

1
Facebook不允许用户在图片上添加文本。
集成Facebook分享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")
  }
}

0

请试试这个:

 let sharePhoto = FBSDKSharePhoto()
photo.image = photo
photo.caption = "you title"

let content = FBSDKShareMediaContent()
content.media = [photo];

您不能预先填写照片标题,而不是让用户自己填写。用户应根据Facebook平台政策(2.3)进行操作。 - EfeHelvaci

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接