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)
}
A view controller that you use to offer standard services from your app.
The title that appears at the top of the the UIActivityItemController is intially simply, "/", with no subtitle, and then after about a second it changes to, "System@snap-2237692", with a subtitle of "File", as per the screenshot below.
The Activity View Controller is a standard view controller that can be used to offer various services from the application. The system provides several standard services, such as copying items to the pasteboard, posting content to social media sites, sending items via email or iMessage, and more.
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With