I am using UIActivityViewController to share image. After the Facebook recent changes . I am able share an image and Url individualy but i am unable to share both image and url at a time. The same code works fine with Mail, twitter etc., Not sure what i am missing for Facebook.
func shareImage() {
var myWebsite = NSURL(string:"http://www.google.com/")
var img: UIImage = currentPhoto!
var shareItems:Array = [img, myWebsite]
let activityViewController:UIActivityViewController = UIActivityViewController(activityItems: shareItems, applicationActivities: nil)
activityViewController.excludedActivityTypes = [UIActivityTypePrint, UIActivityTypePostToWeibo, UIActivityTypeCopyToPasteboard, UIActivityTypeAddToReadingList, UIActivityTypePostToVimeo]
self.presentViewController(activityViewController, animated: true, completion: nil)
}
I have modified your code for swift 2.0:
@IBAction func shareButtonPressed(sender: AnyObject) {
let myWebsite = NSURL(string:"http://www.google.com/")
let img: UIImage = image!
guard let url = myWebsite else {
print("nothing found")
return
}
let shareItems:Array = [img, url]
let activityViewController:UIActivityViewController = UIActivityViewController(activityItems: shareItems, applicationActivities: nil)
activityViewController.excludedActivityTypes = [UIActivityTypePrint, UIActivityTypePostToWeibo, UIActivityTypeCopyToPasteboard, UIActivityTypeAddToReadingList, UIActivityTypePostToVimeo]
self.presentViewController(activityViewController, animated: true, completion: nil)
}
And it is posting a picture with URL.
Result with this code: