I'm making a function using Camera(AVCapture input/output). Now I have a trouble like below.
'layoutSubviews' is not called when iPhone is rotated upsidedown(180 degree) at one time.
(If rotate in 2 step 90 degree and 90 degree, 'layoutSubviews' is called in each rotation)
I'm using AVCaptureVideoPreviewLayer to display camera output.
And to rotate the preview layer, I wrote the code like below.
- (void)layoutSubviews
{
[super layoutSubviews];
[_previewLayer setFrame:self.bounds];
[self setVideoOrientation];
}
- (void)setVideoOrientation
{
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
AVCaptureVideoOrientation videoOrientation = AVCaptureVideoOrientationPortrait;
switch (orientation) {
case UIInterfaceOrientationPortrait:
videoOrientation = AVCaptureVideoOrientationPortrait;
break;
case UIInterfaceOrientationPortraitUpsideDown:
videoOrientation = AVCaptureVideoOrientationPortraitUpsideDown;
break;
case UIInterfaceOrientationLandscapeLeft:
videoOrientation = AVCaptureVideoOrientationLandscapeLeft;
break;
case UIInterfaceOrientationLandscapeRight:
videoOrientation = AVCaptureVideoOrientationLandscapeRight;
break;
default:
break;
}
[_previewLayer.connection setVideoOrientation:videoOrientation];
}
Could you please tell me, if you know, a good solution to call 'layoutSubviews' in 180 degree rotation at one time.