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

Commit cb1974c

Browse files
committed
Updated orientation changes to use UIInterfaceOrientation.
1 parent a0f3f67 commit cb1974c

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

Pod/Classes/WPMediaCapturePreviewCollectionView.m

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ - (void)startCapture
100100
self.captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:self.session];
101101
self.captureVideoPreviewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
102102
self.captureVideoPreviewLayer.frame = viewLayer.bounds;
103-
self.captureVideoPreviewLayer.connection.videoOrientation = [self videoOrientationForDeviceOrientation:[[UIDevice currentDevice] orientation]];
103+
self.captureVideoPreviewLayer.connection.videoOrientation = [self videoOrientationForInterfaceOrientation:[[UIApplication sharedApplication] statusBarOrientation]];
104104
[viewLayer addSublayer:_captureVideoPreviewLayer];
105105
});
106106
}
@@ -110,17 +110,23 @@ - (void)startCapture
110110
- (void)deviceOrientationDidChange:(NSNotification *)notification
111111
{
112112
if (self.captureVideoPreviewLayer.connection.supportsVideoOrientation) {
113-
self.captureVideoPreviewLayer.connection.videoOrientation = [self videoOrientationForDeviceOrientation:[[UIDevice currentDevice] orientation]];
113+
self.captureVideoPreviewLayer.connection.videoOrientation = [self videoOrientationForInterfaceOrientation:[[UIApplication sharedApplication] statusBarOrientation]];
114114
}
115115
}
116116

117-
- (AVCaptureVideoOrientation)videoOrientationForDeviceOrientation:(UIDeviceOrientation)orientation
117+
- (AVCaptureVideoOrientation)videoOrientationForInterfaceOrientation:(UIInterfaceOrientation)orientation
118118
{
119-
if (orientation == UIDeviceOrientationFaceUp || orientation == UIDeviceOrientationFaceDown) {
120-
return AVCaptureVideoOrientationPortrait;
119+
switch (orientation) {
120+
case UIInterfaceOrientationPortrait:
121+
return AVCaptureVideoOrientationPortrait;
122+
case UIInterfaceOrientationPortraitUpsideDown:
123+
return AVCaptureVideoOrientationPortraitUpsideDown;
124+
case UIInterfaceOrientationLandscapeLeft:
125+
return AVCaptureVideoOrientationLandscapeLeft;
126+
case UIInterfaceOrientationLandscapeRight:
127+
return AVCaptureVideoOrientationLandscapeRight;
128+
default:return AVCaptureVideoOrientationPortrait;
121129
}
122-
123-
return (AVCaptureVideoOrientation)orientation;
124130
}
125131

126132
- (BOOL)isAccessibilityElement

0 commit comments

Comments
 (0)