2014-09-12 3 views
1

이상한 문제가 있습니다. 내 앱에 비디오를 녹화하고 있습니다. 장치를 180도 회전 할 때까지 모든 것이 잘 작동합니다. 어떤 가로 모드에서 비디오를 올바르게 시작했는지는 중요하지 않지만 가로 방향으로 예를 들어 돌리면 비디오가 세로로 기록되기 시작합니다. enter image description hereAVCaptureVideoPreviewLayer 방향이 잘못되었습니다

나는 그런 비디오 방향을 설정하려고 : 내가 보여 무승부를 만든 - (BOOL) shouldAutorotate {

UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation]; 
if (orientation == UIInterfaceOrientationLandscapeLeft) { 
    NSLog(@"Left"); 
    captureVideoPreviewLayer.connection.videoOrientation = AVCaptureVideoOrientationLandscapeLeft; 
    return YES; 
} 
else if(orientation == UIInterfaceOrientationLandscapeRight) { 
    NSLog(@"Right"); 
    captureVideoPreviewLayer.connection.videoOrientation = AVCaptureVideoOrientationLandscapeRight; 
    return YES; 
} 

return NO; 

} 을하지만이 전혀 작동하지 않는 것 같습니다. captureVideoPreviewLayer.frame = self.view.bounds;를 설정했습니다. 아직도 작동하지 않습니다.

답변

1

내가 한 방향에 대해 잘 모르겠다는 점을 제외하고 올바른 것을 한 것입니다.

- (void)autoRotateVideoOrientation { 
    UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation; 
    switch (orientation) { 
     case UIInterfaceOrientationPortrait: 
      captureVideoPreviewLayer.connection.videoOrientation = AVCaptureVideoOrientationPortrait; 
      break; 
     case UIInterfaceOrientationPortraitUpsideDown: 
      captureVideoPreviewLayer.connection.videoOrientation = AVCaptureVideoOrientationPortraitUpsideDown; 
      break; 
     case UIInterfaceOrientationLandscapeLeft: 
      captureVideoPreviewLayer.connection.videoOrientation = AVCaptureVideoOrientationLandscapeLeft; 
      break; 
     case UIInterfaceOrientationLandscapeRight: 
      captureVideoPreviewLayer.connection.videoOrientation = AVCaptureVideoOrientationLandscapeRight; 
      break; 
     default: 
      break; 
    } 
} 
+0

'statusBarOrientation'는 아이폰 OS 9.0의 추천되지 않습니다 : 나는 여기

UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation; 

해야 당신이 shouldAutorotate 방법에서 그것을 호출하여 시도 할 수있는 모든 방법을 생각합니다. – rmaddy

관련 문제