Skip to content
This repository was archived by the owner on Jun 19, 2025. It is now read-only.
4 changes: 2 additions & 2 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- WPMediaPicker (0.12)
- WPMediaPicker (0.13)

DEPENDENCIES:
- WPMediaPicker (from `../`)
Expand All @@ -9,7 +9,7 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
WPMediaPicker: d4ce8e9db98b60ab44e7154151dbad135f8e7ff6
WPMediaPicker: 5f39880ac799dbbf41a99f73567a95ab5297dc93

PODFILE CHECKSUM: 7855568785f801c5559f8e70856ad87de227dc95

Expand Down
19 changes: 17 additions & 2 deletions Pod/Classes/WPMediaCapturePreviewCollectionView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
});
}
Expand All @@ -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;
}
}

Expand Down
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
2 changes: 1 addition & 1 deletion WPMediaPicker.podspec
Original file line number Diff line number Diff line change
@@ -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.
Expand Down