From 65e55429e740535fa5574405d18b9aaf7befb368 Mon Sep 17 00:00:00 2001 From: James Frost Date: Thu, 9 Mar 2017 18:26:36 +0000 Subject: [PATCH 1/4] Don't show a preview if no custom preview VC is returned. --- Pod/Classes/WPMediaPickerViewController.m | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/Pod/Classes/WPMediaPickerViewController.m b/Pod/Classes/WPMediaPickerViewController.m index 03c63e1d..247b9674 100644 --- a/Pod/Classes/WPMediaPickerViewController.m +++ b/Pod/Classes/WPMediaPickerViewController.m @@ -709,18 +709,12 @@ - (nullable UIViewController *)previewControllerForTouchLocation:(CGPoint)locati - (UIViewController *)previewViewControllerForAsset:(id )asset { - UIViewController *previewViewController = nil; - if ([self.mediaPickerDelegate respondsToSelector:@selector(mediaPickerController:previewViewControllerForAsset:)]) { - previewViewController = [self.mediaPickerDelegate mediaPickerController:self - previewViewControllerForAsset:asset]; - } - - if (!previewViewController) { - previewViewController = [self defaultPreviewViewControllerForAsset:asset]; + return [self.mediaPickerDelegate mediaPickerController:self + previewViewControllerForAsset:asset]; } - return previewViewController; + return [self defaultPreviewViewControllerForAsset:asset]; } - (UIViewController *)defaultPreviewViewControllerForAsset:(id )asset From 413bdc33e3004b6ac84fbb44aaffe79311e0b663 Mon Sep 17 00:00:00 2001 From: James Frost Date: Thu, 9 Mar 2017 18:27:03 +0000 Subject: [PATCH 2/4] Pass changes to allowsMultipleSelection through to the collectionView. --- Pod/Classes/WPMediaPickerViewController.m | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Pod/Classes/WPMediaPickerViewController.m b/Pod/Classes/WPMediaPickerViewController.m index 247b9674..f59f9ab9 100644 --- a/Pod/Classes/WPMediaPickerViewController.m +++ b/Pod/Classes/WPMediaPickerViewController.m @@ -139,6 +139,15 @@ - (BOOL)isShowingCaptureCell return self.allowCaptureOfMedia && [self isMediaDeviceAvailable] && !self.refreshGroupFirstTime; } +- (void)setAllowMultipleSelection:(BOOL)allowMultipleSelection +{ + _allowMultipleSelection = allowMultipleSelection; + + if (self.isViewLoaded) { + self.collectionView.allowsMultipleSelection = allowMultipleSelection; + } +} + #pragma mark - UICollectionViewDataSource -(void)updateDataWithRemoved:(NSIndexSet *)removed inserted:(NSIndexSet *)inserted changed:(NSIndexSet *)changed moved:(NSArray> *)moves { From d28774f6f02a7c9a7c9b59804e0e0bfb1c675574 Mon Sep 17 00:00:00 2001 From: James Frost Date: Thu, 9 Mar 2017 18:27:37 +0000 Subject: [PATCH 3/4] Update doc comment for preview view controller change. --- Pod/Classes/WPMediaPickerViewController.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Pod/Classes/WPMediaPickerViewController.h b/Pod/Classes/WPMediaPickerViewController.h index 902e6e79..234cc19a 100644 --- a/Pod/Classes/WPMediaPickerViewController.h +++ b/Pod/Classes/WPMediaPickerViewController.h @@ -111,7 +111,8 @@ /** * Asks the delegate for a view controller to push when previewing the specified asset. - * If this method isn't implemented or returns nil, the default view controller will be used. + * If this method isn't implemented, the default view controller will be used. + * If it returns nil, no preview will be displayed. * * @param picker The controller object managing the assets picker interface. * @param asset The asset to be previewed. From ebce520e5418472ab85d7080b20946cb410ba9c5 Mon Sep 17 00:00:00 2001 From: James Frost Date: Thu, 9 Mar 2017 18:27:47 +0000 Subject: [PATCH 4/4] Adds method to clear current asset selection. --- Pod/Classes/WPMediaPickerViewController.h | 5 +++++ Pod/Classes/WPMediaPickerViewController.m | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/Pod/Classes/WPMediaPickerViewController.h b/Pod/Classes/WPMediaPickerViewController.h index 234cc19a..bd51732d 100644 --- a/Pod/Classes/WPMediaPickerViewController.h +++ b/Pod/Classes/WPMediaPickerViewController.h @@ -165,5 +165,10 @@ */ - (void)setGroup:(nonnull id)group; +/** + * Clears the current asset selection in the picker. + */ +- (void)clearSelectedAssets:(BOOL)animated; + @end diff --git a/Pod/Classes/WPMediaPickerViewController.m b/Pod/Classes/WPMediaPickerViewController.m index f59f9ab9..3d9512bc 100644 --- a/Pod/Classes/WPMediaPickerViewController.m +++ b/Pod/Classes/WPMediaPickerViewController.m @@ -148,6 +148,15 @@ - (void)setAllowMultipleSelection:(BOOL)allowMultipleSelection } } +- (void)clearSelectedAssets:(BOOL)animated +{ + for (NSIndexPath *indexPath in [self.collectionView indexPathsForSelectedItems]) { + [self.collectionView deselectItemAtIndexPath:indexPath animated:animated]; + } + + [self.selectedAssets removeAllObjects]; +} + #pragma mark - UICollectionViewDataSource -(void)updateDataWithRemoved:(NSIndexSet *)removed inserted:(NSIndexSet *)inserted changed:(NSIndexSet *)changed moved:(NSArray> *)moves {