최신 SDK가 포함 된 iOS 앱을 개발하고 있습니다.UIInterfaceOrientation은 Landscape이지만 UIView는 Portrait 모드입니다.
저는 LandscapeRight 방향 만 지원하는 카메라 앱을 개발하고 있습니다.
메인 주 ViewController
AVCaptureVideoPreviewLayer
에 UIView
을 추가했습니다. 다른 말로하면, 주 ViewController
주보기가 있고 videoPreviewView
이라는 또 다른보기가 AVCaptureVideoPreviewLayer
입니다.
BOUNDS: {{0, 0}, {320, 480}}
그러나 UIInterfaceOrientation
이 UIInterfaceOrientationLandscapeRight
하고 그 방향을 함께 내가 이러한 값을 얻을 것입니다 :
BOUNDS: {{0, 0}, {480, 320}}
을 나는이 로그를 얻을
- (void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self setUpVideo];
}
- (void)setUpVideo
{
NSLog(@"Set up video");
if (DataExchanger.cameraManager != nil)
{
UIView *view = [self videoPreviewView];
CALayer *viewLayer = [view layer];
[viewLayer setMasksToBounds:YES];
AVCaptureVideoPreviewLayer *newCaptureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:DataExchanger.cameraManager.captureSession];
CGRect bounds = [view bounds];
NSLog(@"BOUNDS: %@", NSStringFromCGRect(bounds));
[newCaptureVideoPreviewLayer setFrame:bounds];
[newCaptureVideoPreviewLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill];
[viewLayer insertSublayer:newCaptureVideoPreviewLayer below:[[viewLayer sublayers] objectAtIndex:0]];
}
}
:
나는 viewWillAppear:
방법에 AVCaptureVideoPreviewLayer
을 설정
또 다른 문제는 나는 비디오를 -90도으로 돌렸다.
이 결과는 stackoverflow question이지만, - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
메서드는 실행되지 않습니다.
무슨 일입니까? 이 문제를 어떻게 해결할 수 있습니까?
최신 SDK와 iOS 5.0 이상을 지원합니다. 어떤 버전의 대답을 사용해야합니까? 하지만 이제는 두 번째 옵션을 사용하고 있으며이 문제가 발생하여 내 대답이 내 문제를 해결하지 못했다고 생각합니다. – VansFannel
누군가가 내 답변 3 개를 임의로, 게시 후 3 개월 동안 downvote한다면; 이유가있는 경우 의견을 게시하십시오 (있는 경우). – Spectravideo328