Skip to content
This repository was archived by the owner on Jun 19, 2025. It is now read-only.

Commit 0de8ebe

Browse files
author
Sérgio Estêvão
committed
Merge pull request #91 from wordpress-mobile/issue/apply_media_filter_to_capture
Apply media filter to capture picker
2 parents ee0cb05 + c405d0d commit 0de8ebe

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

Example/WPMediaPicker/DemoViewController.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ - (void)viewDidLoad
3131
self.dateFormatter.timeStyle = NSDateFormatterMediumStyle;
3232
[self.tableView registerClass:[WPMediaGroupTableViewCell class] forCellReuseIdentifier:NSStringFromClass([WPMediaGroupTableViewCell class])];
3333
self.options = @{
34-
MediaPickerOptionsShowMostRecentFirst:@(NO),
35-
MediaPickerOptionsUsePhotosLibrary:@(NO),
34+
MediaPickerOptionsShowMostRecentFirst:@(YES),
35+
MediaPickerOptionsUsePhotosLibrary:@(YES),
3636
MediaPickerOptionsShowCameraCapture:@(YES),
3737
MediaPickerOptionsAllowMultipleSelection:@(YES)
3838
};

Pod/Classes/WPMediaCollectionViewController.m

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -559,9 +559,20 @@ - (BOOL)isMediaDeviceAvailable
559559
- (void)showMediaCaptureViewController
560560
{
561561
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
562-
imagePickerController.mediaTypes =
563-
[UIImagePickerController availableMediaTypesForSourceType:
564-
UIImagePickerControllerSourceTypeCamera];
562+
NSMutableSet *mediaTypes = [NSMutableSet setWithArray:[UIImagePickerController availableMediaTypesForSourceType:
563+
UIImagePickerControllerSourceTypeCamera]];
564+
switch (self.filter) {
565+
case(WPMediaTypeImage): {
566+
[mediaTypes intersectSet:[NSSet setWithArray:@[(__bridge NSString *)kUTTypeImage]]];
567+
} break;
568+
case(WPMediaTypeVideo): {
569+
[mediaTypes intersectSet:[NSSet setWithArray:@[(__bridge NSString *)kUTTypeMovie]]];
570+
} break;
571+
default: {
572+
//Don't intersect at all
573+
}
574+
}
575+
imagePickerController.mediaTypes = [mediaTypes allObjects];
565576
imagePickerController.delegate = self;
566577
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
567578
imagePickerController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;

0 commit comments

Comments
 (0)