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 8782811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:39:54+00:00 2026-06-13T20:39:54+00:00

I need to know when orientation switch from portrait to landscape and vise versa.

  • 0

I need to know when orientation switch from portrait to landscape and vise versa.
If I choose to listen to UIDeviceOrientationDidChangeNotification I get face up, face down etc, but I need to run code only when there is a interface rotation.

I could do as http://the.ichibod.com/kiji/how-to-handle-device-rotation-for-uiviews-in-ios/

- (void)deviceOrientationDidChange:(NSNotification *)notification {

 //Obtaining the current device orientation
  UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];

 //Ignoring specific orientations
  if (orientation == UIDeviceOrientationFaceUp || orientation == UIDeviceOrientationFaceDown     || orientation == UIDeviceOrientationUnknown || currentOrientation == orientation) {
   return;
  }

  [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(relayoutLayers) object:nil];
  //Responding only to changes in landscape or portrait
  currentOrientation = orientation;
}

What is the best approach?

  • 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-13T20:39:55+00:00Added an answer on June 13, 2026 at 8:39 pm

    I had similar problems orientating my views when using device orientation. It has up, down, left and right but also unknown and another which I yet to figure it out what it means (int 5 on the enum, 0 being Unknown). Anyways, what I ended up resorting to was to detect the status bar orientation. That remains more consistency for what the user is seeing.

    UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
    

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know how to get an orientation vector from the accelerometer and the magnetic
I know I can specific application orientation (Portrait or Landscape) through manifest file. My
I need to get device orientation from a ViewController. I cannot base on :
I need to know how to exclude files/folders from php generated zip. Here is
I need to know is it possible to rotate the orientation of all X-based
I need to get the interface orientation in the viewWillAppear method of my UIViewController.
I've got an old app that I need to get to print in landscape
Need to know this so that i could send DTMF and that is going
Need to know which event triggered after text selection done in Apple iPad. It
I need to know how to change background of expanded list item when it

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.