我正在使用 - FBSDKShareKit (4.40.0): 我想在 Facebook 上分享图片。它应该是可点击的,并且应该像 Endomondo 应用程序一样打开网站。
我已经尝试过这段代码,但 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/