Skip to content
This repository was archived by the owner on Jun 19, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Pod/Classes/WPMediaPickerViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -164,5 +165,10 @@
*/
- (void)setGroup:(nonnull id<WPMediaGroup>)group;

/**
* Clears the current asset selection in the picker.
*/
- (void)clearSelectedAssets:(BOOL)animated;

@end

30 changes: 21 additions & 9 deletions Pod/Classes/WPMediaPickerViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,24 @@ - (BOOL)isShowingCaptureCell
return self.allowCaptureOfMedia && [self isMediaDeviceAvailable] && !self.refreshGroupFirstTime;
}

- (void)setAllowMultipleSelection:(BOOL)allowMultipleSelection
{
_allowMultipleSelection = allowMultipleSelection;

if (self.isViewLoaded) {
self.collectionView.allowsMultipleSelection = 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<id<WPMediaMove>> *)moves {
Expand Down Expand Up @@ -709,18 +727,12 @@ - (nullable UIViewController *)previewControllerForTouchLocation:(CGPoint)locati

- (UIViewController *)previewViewControllerForAsset:(id <WPMediaAsset>)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 <WPMediaAsset>)asset
Expand Down