ios - 共享图片点击即可打开 URL

标签 ios swift facebook fbsdksharekit

我正在使用 - FBSDKShareKit (4.40.0): 我想在 Facebook 上分享图片。它应该是可点击的,并且应该像 Endomondo 应用程序一样打开网站。

enter image description here 我已经尝试过这段代码,但 url 覆盖了照片并且它们没有显示:

    let sharePhoto = FBSDKSharePhoto()
    sharePhoto.image = someImage

    let content = FBSDKSharePhotoContent()
    content.photos = [sharePhoto];
    content.contentURL = URL(string: "https://facebook.com")!
    FBSDKShareDialog.show(from: self, with: content, delegate: nil)

他们是怎么做到的?

最佳答案

使用它在 Facebook 上分享

导入社交

func shareToFb(_ yourImage:UIImage!)

    {
     let facebookURL = URL(string: "fb://")
      if (UIApplication.shared.canOpenURL(facebookURL!)) {
      let vc = SLComposeViewController(forServiceType:SLServiceTypeFacebook)
             vc?.add(yourImage)
                    vc?.setInitialText("Initial text here.")
                    self.present(vc!, animated: true, completion: nil)
                }
                else {
                    let urlStr = "https://itunes.apple.com/us/app/workplace-by-facebook/id944921229?mt=8"
                    if #available(iOS 10.0, *) {
                        UIApplication.shared.open(URL(string: urlStr)!, options: [:], completionHandler: nil)

                    } else {
                        UIApplication.shared.openURL(URL(string: urlStr)!)
                    }
                }


            }

关于ios - 共享图片点击即可打开 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55005657/

相关文章:

javascript - Facebook 弹出窗口在 iOS Safari、HTML5 Canvas 按钮上被阻止

ios - 检测 CA :TRUE in x509 Basic Contraints

ios - UIView 的框架大小问题

ios - 在启用 Bitcode 的情况下导出时出错(找不到体系结构 armv7 的符号)

arrays - Swift 3 - 使类可迭代

swift - OSX/swift : Call a function when internet connection is established/restored

ios - Expo - 在 iOS 12 上禁用自动填充强密码(自动填充)

ios - 如何制作带有完成按钮的 UIPickerView?

html - 本地化 Facebook OG 标签

python - 监控 Facebook 页面