title: Force camera view in landscape with orientation lock on
body: <p>I am developing an augmented reality game, and I've encountered an issue with the orientation of the camera view when the orientation lock of the device is on. </p>
  
  <p>I am using this code to load the camera view inside of a View:</p>
  
  <pre><code>AVCaptureSession *session = [[AVCaptureSession alloc] init];
  AVCaptureVideoPreviewLayer *captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];
  captureVideoPreviewLayer.frame = self.sessionView.bounds;
  [self.sessionView.layer addSublayer:captureVideoPreviewLayer];
  CGRect bounds=sessionView.layer.bounds;
  captureVideoPreviewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
  captureVideoPreviewLayer.bounds=bounds;
  captureVideoPreviewLayer.orientation = [[UIDevice currentDevice] orientation];
  captureVideoPreviewLayer.position=CGPointMake(CGRectGetMidX(bounds), CGRectGetMidY(bounds));
  
  AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
  // device.position ;
  NSError *error = nil;
  AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device error:&amp;error];
  if ([device hasTorch]) {
      ([device supportsAVCaptureSessionPreset:AVCaptureSessionPreset1280x720]);
  }
  else {
      ([device supportsAVCaptureSessionPreset:AVCaptureSessionPreset640x480]);
  }
  [session addInput:input];
  [session startRunning];
  </code></pre>
  
  <p>And to keep the orientation of the app in landscape right, I have only that box in the Xcode app Summary selected, with:</p>
  
  <pre><code>- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
  {
  return ((interfaceOrientation == UIInterfaceOrientationLandscapeRight));
  }
  </code></pre>
  
  <p>When the device has orientation lock on (double click home button, swipe right, tap orientation icon) the camera view is in portrait, with the rest of the game in landscape. Is there any way to fix this? From what I've read it's not possible to turn off orientation lock when the user opens the game.</p>