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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:20:39+00:00 2026-05-26T06:20:39+00:00

For better user experience I had the following in my code: if (allowLandscape) {

  • 0

For better user experience I had the following in my code:

if (allowLandscape) {
    return UIInterfaceOrientationIsLandscape(toInterfaceOrientation) || toInterfaceOrientation == UIInterfaceOrientationPortrait;
}
else {
    return toInterfaceOrientation == UIInterfaceOrientationPortrait;
}

So, if allowLandscape is set to YES, user can play with the app in all typical device orientations. But allowLandscape can be set to NO anytime, and I want to rotate the UIViewController back to portrait orientation.

The following code only works if the user manually change the device orientation. So if allowLandscape was YES, he could rotate the device and the interface orientation followed the orientation change. But if he stays in landscape orientation, and allowLandscape will be set to NO, he stays in the landscape orientation, until he moves iPhone to the portrait orientation – now portrait orientation cannot be changed if the allowLandscape is still NO.

What I want to accomplish is to call some method, to force the ViewController to refresh it’s orientation with animation if it’s possible.

Calling the method:

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:YES];

does only change the status bar, but the interface remains in the previous orientation. I don’t want to use any undocumented APIs.

  • 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-05-26T06:20:39+00:00Added an answer on May 26, 2026 at 6:20 am

    Here is the solution:

        [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
        [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
    

    By adding this code, view controller asks again, in which orientation should it present its view.

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

Sidebar

Related Questions

Ajax seems to give a better user experience, but I'm not so sure if
Which constitutes better object oriented design? Class User { id {get;set} } Class Office
I am interesting in creating a better User Experience (UX). There are a lot
I see various frameworks being launched that promise Rich Ui and better User experience
Which one is better from performance view user control or custom control? Right now
Is it better to have a different CSS file for each user-agent or is
which one will be better to use default magic quotes or user defined addslash/stripslash
Is there a better way than this to determine the row a user double-clicked
Which class design is better and why? public class User { public String UserName;
Better yet, how can I make My Computer always open in Explorer as well?

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.