1

All that shows up when I use the UIImagePickerController is a library of photos. I have an mp4 video saved to the simulator library, but it never shows up in the list when I access the simulator library programmatically with UIImagePickerController. Is there something I'm doing wrong?

play2win
  • 331
  • 8
  • 25
  • 1
    Picking videos from the iPhone Library does not work on the iOS Simulator. Try it on a real iPhone. Please check the answer for this question in SO: http://stackoverflow.com/questions/10480170/how-to-select-any-video-or-movie-file-from-uiimagepickercontroller – muneeb Apr 14 '15 at 21:38
  • Thank you for the response. I did check other questions. I just didn't want to assume those answers applied to every version of iOS and every situation. I'm very new to programming in Swift and for iOS. Thanks for your help. – play2win Apr 14 '15 at 22:18

2 Answers2

1

You just need to add a video to your simulator.

Drag and drop a video file on top of the simulator window. It will show in the photos app and whenever you want a video for upload.

Eric
  • 7,787
  • 5
  • 19
  • 34
0

Based on Swift 2.2

Your code may look like this:

@IBAction func selectImageFromPhotoLibrary(sender: UIBarButtonItem) {

    let imagePickerController = UIImagePickerController()

    imagePickerController.sourceType = .PhotoLibrary
    imagePickerController.delegate = self

    imagePickerController.mediaTypes = ["public.image", "public.movie"]
    presentViewController(imagePickerController, animated: true, completion: nil)
}

Actually you can get the answers from the Apple Document:

UIImagePickerController Class Reference

The useful method is class func availableMediaTypesForSourceType.

You can try this:

let types = UIImagePickerController.availableMediaTypesForSourceType(.PhotoLibrary)
print(types)

Then you know videos types are named public.movie , not kUTTypeMovie anymore.

XueYu
  • 2,355
  • 29
  • 33