Élodie Petit Élodie Petit - 22 days ago 7
iOS Question

Unknown activity items supplied for ActivityViewController

I am trying to share videos from my app using a UIActivityViewController. Below is the code I use:

var url = NSURL(string: path!)!
var activityViewController = UIActivityViewController(activityItems: [url], applicationActivities: nil)

self.presentViewController(activityViewController, animated: true, completion: { () -> Void in })


The path points to a valid .mov file so no problems there. When I present the activity view controller I get the error: Unknown activity items supplied with the path to the .mov file and the sharing options only show AirDrop.

The app is running on iOS 8.

Any ideas?

EDIT I found out that when I save the video to camera roll. the user can share it with Photos app to any app. So there's nothing wrong with the video format I guess.

Answer

You should use init?(fileURLWithPath path: String, isDirectory isDir: Bool) if the movie is in resource bundle.

If you use imagePicker controller to select the video, you can get the url from info dictionary using the key UIImagePickerControllerMediaURL, the corresponding delegate method is didFinishPickingMediaWithInfo.

Comments