0

I have one table tableviewController. On clicking one of the cell, the next viewController opens a cam and use AVCaptureVideoPreviewLayer to show video. To support orientations, I have added these lines of codes.

  - (NSUInteger)supportedInterfaceOrientations
  {
  return UIInterfaceOrientationMaskAll;
  //return UIInterfaceOrientationMaskLandscapeRight;
  }
  - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
  duration:(NSTimeInterval)duration     
  {
  [[(AVCaptureVideoPreviewLayer *)[[self previewView] layer] connection] setVideoOrientation:   
  (AVCaptureVideoOrientation)toInterfaceOrientation];
  }

But I want to lock my second view controller that shows video in landscape mode only. If the iPhone is in portrait mode, still I want that it will show only landscape mode. Like in some games, orientation is locked.

1 Answers1

0

TRy presenting the second view controller and set the orientation as landscape in

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation

Refer : https://stackoverflow.com/a/12897383/667586 for details

Community
  • 1
  • 1
Abhishek Bedi
  • 5,205
  • 2
  • 36
  • 62