问题
Please don't mark duplicate already seen iOS11: UIActivityViewController not successfully sharing UIImage to 3rd party apps
So I am trying to share Image + URL with UIActivityViewController
.
However when tap on facebook it only show URL
, Image is not showingup
Here is my code
@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);
}
}
}
If I remove URL
then I can able to share image,
Only URL Visible for sharing
Is there any workaround to share Image with URL or any text ?
回答1:
it's impossible to share images and URL at the same time currently
来源:https://stackoverflow.com/questions/50486049/uiactivityviewcontroller-facebook-sharing-url-image-and-url-text-not-working