I am trying to share a video and image from a URL using UIActivityViewController. If I try with an Image I have not problems i try to both i face issues.
guard let urlData = NSData(contentsOf: photo.videoURL! as URL) else {
return
}
let paths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)
let docDirectory = paths[0]
let filePath = "\(docDirectory)/tmpVideo.mov"
urlData.write(toFile: filePath, atomically: true)
// File Saved
let videoLink = NSURL(fileURLWithPath: filePath)
let objectsToShare = [imageData,videoLink] //comment!, imageData!, myWebsite!]
let activityViewController = UIActivityViewController(activityItems: items, applicationActivities:nil)
if UIDevice.current.userInterfaceIdiom == .pad {
activityViewController.popoverPresentationController?.sourceView = viewController.view
activityViewController.popoverPresentationController?.sourceRect = CGRectMake(CGRectGetMidX(viewController.view.bounds), CGRectGetMidY(viewController.view.bounds),0,0)
}
viewController.present(activityViewController, animated: true, completion: nil)
Anyone give solution to share image and video using UIActivityViewController