Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8977201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:19:06+00:00 2026-06-15T19:19:06+00:00

I am developing an augmented reality game, and I’ve encountered an issue with the

  • 0

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.

I am using this code to load the camera view inside of a View:

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:&error];
if ([device hasTorch]) {
    ([device supportsAVCaptureSessionPreset:AVCaptureSessionPreset1280x720]);
}
else {
    ([device supportsAVCaptureSessionPreset:AVCaptureSessionPreset640x480]);
}
[session addInput:input];
[session startRunning];

And to keep the orientation of the app in landscape right, I have only that box in the Xcode app Summary selected, with:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return ((interfaceOrientation == UIInterfaceOrientationLandscapeRight));
}

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T19:19:07+00:00Added an answer on June 15, 2026 at 7:19 pm

    The reason why your Preview layer is not orientating is due the fact that you are using deprecated API and moreover you are not updating the Video orientation at the change of device orientation.

    1. Remove the deprecated API i.e in your code instead of

      captureVideoPreviewLayer.orientation
      

      use videoOrientation property i.e

      captureVideoPreviewLayer.connection.videoOrientation 
      
    2. Update the video orientation in shouldAutorotate as follows:

      - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
      {
      
          if(interfaceOrientation == UIInterfaceOrientationLandscapeRight)
          {
             captureVideoPreviewLayer.connection.videoOrientation = AVCaptureVideoOrientationLandscapeRight
          }
      
            // and so on for other orientations
      
          return ((interfaceOrientation == UIInterfaceOrientationLandscapeRight));
      }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing an augmented reality application for Android that uses the phone's camera to
I have been developing C++ code for augmented reality on ARM devices and optimization
I'm developing an iPhone application. I have a UIView used to augmented reality. I
I'm doing my first steps in OpenGL for Android, for developing Augmented Reality apps
Developing a game with AndEngine GLES2 I am having an issue trying to change
Developing a simple game for the iPhone, what gives a better performance? Using a
I am developing an Augmented Reality app based on location. It is working perfectly
I am developing an augmented reality iOS app (iPhone/iPad/iPod) and I would like to
I am developing an Augmented Reality SDK on OpenCV. I had some problems to
I have a small augmented reality app that I'm developing and would like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.