UIActivityViewController Facebook共享URL + IMAGE和URL + TEXT不起作用

时间:2018-05-23 10:30:37

标签: swift4 ios11 uiactivityviewcontroller

请不要标记已见过iOS11: UIActivityViewController not successfully sharing UIImage to 3rd party apps

的重复内容

所以我尝试与UIActivityViewController分享图片+网址。 但是,当点击Facebook时它只显示URL,图像不显示

这是我的代码

@IBAction func btnShareTapped(_ sender: UIButton) {
    if let image = self.imgBackground.image, let jpgImage = UIImageJPEGRepresentation(image, 0.8) {
        let shareItems:Array = [jpgImage,URL(string: "https://www.facebook.com")] as [Any]
        let activityViewController:UIActivityViewController = UIActivityViewController(activityItems: shareItems, applicationActivities: nil)
        activityViewController.excludedActivityTypes = [UIActivityType.print, UIActivityType.postToWeibo, UIActivityType.copyToPasteboard, UIActivityType.addToReadingList, UIActivityType.postToVimeo]
        self.present(activityViewController, animated: true, completion: nil)

        DispatchQueue.main.async {
            self.present(activityViewController, animated: true, completion: nil);
        }
    }
}

如果我删除URL,那么我就可以共享图片了

只有可见的网址

Only URL Visible not image

是否有与URL或任何文本共享图像的解决方法?

1 个答案:

答案 0 :(得分:0)

当前无法同时共享图像和URL