Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show videos only in UIImagePickerController

I am using following code to present UIImagePickerController.For some particular scenario I want only videos.And using the following code.

UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
imagePickerController.sourceType = sourceType;
imagePickerController.delegate = self;
imagePickerController.allowsEditing=NO;

imagePickerController.mediaTypes=[[NSArray alloc] initWithObjects:(NSString *)kUTTypeMovie,nil];

[self presentViewController:imagePickerController animated:YES completion:nil];

But it showing Camera Roll,My Photo Stream and Videos in a tableview.If I open any folder the contents are only videos.I want Only Videos how can I achieve this.Also the title Photos,I want to change that also toVideos.

like image 442
Jeff Avatar asked Apr 16 '14 14:04

Jeff


1 Answers

Swift 3 update :

let videoPicker = UIImagePickerController()  
videoPicker.delegate = self
videoPicker.sourceType = .photoLibrary
videoPicker.mediaTypes = [kUTTypeMovie as String]
self.present(videoPicker, animated: true, completion: nil)

Import import MobileCoreServices and add delegates UIImagePickerControllerDelegate and UINavigationControllerDelegate in the top

The presented modal will have "Photos" title. You can change it like this :

func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {
        viewController.navigationItem.title = "Choose Video"
}
like image 54
ivanharmat Avatar answered Oct 04 '22 00:10

ivanharmat