diff --git a/Example/Podfile.lock b/Example/Podfile.lock index f35bd512..985e2a03 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - WPMediaPicker (0.12) + - WPMediaPicker (0.13) DEPENDENCIES: - WPMediaPicker (from `../`) @@ -9,7 +9,7 @@ EXTERNAL SOURCES: :path: "../" SPEC CHECKSUMS: - WPMediaPicker: d4ce8e9db98b60ab44e7154151dbad135f8e7ff6 + WPMediaPicker: 5f39880ac799dbbf41a99f73567a95ab5297dc93 PODFILE CHECKSUM: 7855568785f801c5559f8e70856ad87de227dc95 diff --git a/Pod/Classes/WPMediaCapturePreviewCollectionView.m b/Pod/Classes/WPMediaCapturePreviewCollectionView.m index 3e50d57f..1c234bf6 100644 --- a/Pod/Classes/WPMediaCapturePreviewCollectionView.m +++ b/Pod/Classes/WPMediaCapturePreviewCollectionView.m @@ -100,7 +100,7 @@ - (void)startCapture self.captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:self.session]; self.captureVideoPreviewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill; self.captureVideoPreviewLayer.frame = viewLayer.bounds; - self.captureVideoPreviewLayer.connection.videoOrientation = (AVCaptureVideoOrientation)[[UIDevice currentDevice] orientation]; + self.captureVideoPreviewLayer.connection.videoOrientation = [self videoOrientationForInterfaceOrientation:[[UIApplication sharedApplication] statusBarOrientation]]; [viewLayer addSublayer:_captureVideoPreviewLayer]; }); } @@ -110,7 +110,22 @@ - (void)startCapture - (void)deviceOrientationDidChange:(NSNotification *)notification { if (self.captureVideoPreviewLayer.connection.supportsVideoOrientation) { - self.captureVideoPreviewLayer.connection.videoOrientation = (AVCaptureVideoOrientation)[[UIDevice currentDevice] orientation]; + self.captureVideoPreviewLayer.connection.videoOrientation = [self videoOrientationForInterfaceOrientation:[[UIApplication sharedApplication] statusBarOrientation]]; + } +} + +- (AVCaptureVideoOrientation)videoOrientationForInterfaceOrientation:(UIInterfaceOrientation)orientation +{ + switch (orientation) { + case UIInterfaceOrientationPortrait: + return AVCaptureVideoOrientationPortrait; + case UIInterfaceOrientationPortraitUpsideDown: + return AVCaptureVideoOrientationPortraitUpsideDown; + case UIInterfaceOrientationLandscapeLeft: + return AVCaptureVideoOrientationLandscapeLeft; + case UIInterfaceOrientationLandscapeRight: + return AVCaptureVideoOrientationLandscapeRight; + default:return AVCaptureVideoOrientationPortrait; } } diff --git a/Pod/Classes/WPMediaPickerViewController.h b/Pod/Classes/WPMediaPickerViewController.h index 902e6e79..bd51732d 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. @@ -164,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 03c63e1d..3d9512bc 100644 --- a/Pod/Classes/WPMediaPickerViewController.m +++ b/Pod/Classes/WPMediaPickerViewController.m @@ -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> *)moves { @@ -709,18 +727,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 diff --git a/WPMediaPicker.podspec b/WPMediaPicker.podspec index 24eb2d71..16a6188a 100644 --- a/WPMediaPicker.podspec +++ b/WPMediaPicker.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "WPMediaPicker" - s.version = "0.12" + s.version = "0.13" s.summary = "WPMediaPicker is an iOS controller that allows capture and picking of media assets." s.description = <<-DESC WPMediaPicker is an iOS controller that allows capture and picking of media assets.