Reputation: 1403
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.
Upvotes: 11
Views: 6897
Reputation: 133
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"
}
Upvotes: 12
Reputation: 502
#import <MobileCoreServices/MobileCoreServices.h>
and
[controller setMediaTypes:@[(NSString *)kUTTypeMovie]];
Upvotes: 4
Reputation: 4437
You cannot get all the videos collection(from camera roll, photo library) in a single shot, you do need to navigate to and from "Camera roll", "Photo Library" to choose the desired video.
You can choose source type to any of the following enum
typedef NS_ENUM(NSInteger, UIImagePickerControllerSourceType) {
UIImagePickerControllerSourceTypePhotoLibrary,
UIImagePickerControllerSourceTypeCamera,
UIImagePickerControllerSourceTypeSavedPhotosAlbum
};
and set the desired media types.
Upvotes: 0