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

  • Home
  • SEARCH
  • 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 9274869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:27:15+00:00 2026-06-18T16:27:15+00:00

I want to capture an image with the camera using AVCaptureSession. It works ok,

  • 0

I want to capture an image with the camera using AVCaptureSession.

It works ok, I start the camera and I can get the output. However, I have some problems with video orientation when I rotate the device.

First, I want to support landscape left and right orientations and may be portrait modes too later.

I implement:

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

When I rotate the device, it rotates the app from landscape left to landscape right or vice versa, but I only see the camera correctly when I’m on landscape left. When the app is on landscape right, the video is rotated by 180 degrees.

Thank you very much.

Update:

I’ve tried Spectravideo328 answer but I have an error when I try to rotate the device and the app crash. This is the error:

[AVCaptureVideoPreviewLayer connection]: unrecognized selector sent to instance 0xf678210

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AVCaptureVideoPreviewLayer connection]: unrecognized selector sent to instance 0xf678210'

The error occurs in this line:

AVCaptureConnection *previewLayerConnection=self.previewLayer.connection;

I put it inside shouldAutorotateToInterfaceOrientation method.
Do you know what could be the reason of this error?

Thanks

  • 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-18T16:27:17+00:00Added an answer on June 18, 2026 at 4:27 pm

    The default camera orientation is oddly enough UIInterfaceOrientationLeft.

    The camera orientation does not change with the rotation of the device. They are separate. You have to adjust the camera orientation manually:

    Put the following in a method that you pass toInterfaceOrientation to (maybe you call it from shouldAutorotateToInterfaceOrientation above so that the device rotates and the camera rotates):

    You have to get the preview Layer connection first

    AVCaptureConnection *previewLayerConnection=self.previewLayer.connection;
    
    if ([previewLayerConnection isVideoOrientationSupported])
    {
        switch (toInterfaceOrientation)
        {
            case UIInterfaceOrientationPortrait:
                [previewLayerConnection setVideoOrientation:AVCaptureVideoOrientationPortrait];
                break;
            case UIInterfaceOrientationLandscapeRight:
                [previewLayerConnection setVideoOrientation:AVCaptureVideoOrientationLandscapeRight]; //home button on right. Refer to .h not doc
                break;
            case UIInterfaceOrientationLandscapeLeft:
                [previewLayerConnection setVideoOrientation:AVCaptureVideoOrientationLandscapeLeft]; //home button on left. Refer to .h not doc
                break;
            default:
                [previewLayerConnection setVideoOrientation:AVCaptureVideoOrientationPortrait]; //for portrait upside down. Refer to .h not doc
                break;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want's to display image capture using device camera and for that i have
i can capture image using avfoundation.framework as shown in AVCam Demo but i want
I want to capture image using camera and want image path. I try following
I am using an activity to capture image i want to start a finish
I capture an image using the photo or camera task and I want to
in my app i am using camera to capture an image and i want
I have created one sample application.For capture image using camera.It is working fine.After capture
In my application I want to capture two images using camera and then I
I want a camera view that will capture a image to a local file
I want to capture a webcam feed using my camera. For that I am

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.