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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:01:39+00:00 2026-06-18T05:01:39+00:00

I find many question to force UIViewController to landscape as default: How to force

  • 0

I find many question to force UIViewController to landscape as default:
How to force a UIViewController to Portrait orientation in iOS 6
And try this:

- (BOOL)shouldAutorotate
{
    return YES;
}

-(NSUInteger)supportedInterfaceOrientations

{
    return UIInterfaceOrientationMaskLandscape;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationLandscapeLeft;
}

But when I use UIViewController inside UINavigationController, I can’t force to landscape.Please help!

*Work NOT ok

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];

    UINavigationController *navControl = [[UINavigationController alloc] initWithRootViewController:self.viewController];
    [navControl setNavigationBarHidden:YES];
    self.window.rootViewController = navControl;

    [self.window makeKeyAndVisible];
    return YES;
}

*Work OK:

self.window.rootViewController = self.viewController;
  • 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-18T05:01:40+00:00Added an answer on June 18, 2026 at 5:01 am

    Best way to do this is the create extend UINavigationController and write your orientation function inside the extended class.

    Class Declaration:

    @interface MyNavigationControllerViewController : UINavigationController
    
    @property(nonatomic, assign) UIInterfaceOrientation orientation;
    @property(nonatomic, assign) NSUInteger supportedInterfaceOrientatoin;
    @end
    

    Implementation of MyNavigationController

    @implementation MyNavigationController
    
    @synthesize supportedInterfaceOrientatoin = _supportedInterfaceOrientatoin;
    
    @synthesize orientation = _orientation;
    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
    {
        self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
        if (self) {
            // Custom initialization
            _supportedInterfaceOrientatoin = UIInterfaceOrientationMaskLandscape;
            _orientation = UIInterfaceOrientationLandscapeLeft;
        }
        return self;
    }
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view.
    }
    
    - (void)didReceiveMemoryWarning
    {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    - (BOOL)shouldAutorotate
    {
        return YES;
    }
    
    -(NSUInteger)supportedInterfaceOrientations
    
    {
        return _supportedInterfaceOrientatoin;
    }
    
    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
    {
        return self.orientation;
    }
    
    @end
    

    and use your extended like MyNavigationController as navigation controller to your rootviewcontroller.

    @interface AppDelegate : UIResponder <UIApplicationDelegate>
    
    @property (strong, nonatomic) UIWindow *window;
    
    @property (strong, nonatomic) ViewController *viewController;
    @property (strong, nonatomic) MyNavigationControllerViewController *myNavController;
    
    - (void) reloadAppDelegateRootViewControllerLandscape;
    - (void) reloadAppDelegateRootViewController;
    @end
    

    So your application delegate didfinishlounchingwithoptions code will be as follow.

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
    
        self.myNavController = [[MyNavigationController alloc] initWithRootViewController:self.viewController];
        [self.myNavController setNavigationBarHidden:YES];
        self.window.rootViewController = self.myNavController;
    
        [self.window makeKeyAndVisible];
        return YES;
    }
    

    Only way you can provide different orientation for two different view with same navigation controller isto reload the navigation controller itself. So if you add two methods

    - (void) reloadAppDelegateRootViewController{
        [[[UIApplication sharedApplication].delegate window] setRootViewController:nil];
        [(MyNavigationControllerViewController *)self.myNavController setOrientation:UIInterfaceOrientationPortrait];
        [(MyNavigationControllerViewController *)self.myNavController setSupportedInterfaceOrientatoin:UIInterfaceOrientationMaskAll];
        [[[UIApplication sharedApplication].delegate window] setRootViewController:self.myNavController];
    }
    
    - (void) reloadAppDelegateRootViewControllerLandscape{
        [[[UIApplication sharedApplication].delegate window] setRootViewController:nil];
        [(MyNavigationControllerViewController *)self.myNavController setOrientation:UIInterfaceOrientationLandscapeLeft];
        [(MyNavigationControllerViewController *)self.myNavController setSupportedInterfaceOrientatoin:UIInterfaceOrientationMaskLandscape];
        [[[UIApplication sharedApplication].delegate window] setRootViewController:self.myNavController];
    }
    

    and call these function after pushing and pop views.

    Note:- I don’t know whether it is a good way or bad way.

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

Sidebar

Related Questions

I know this question has been asked many times before but I can't find
There are many questions like this but I can't find one that seems to
I've seen many questions like this, but i can't seem to find the answer:
Having searched regarding this issue beforehand, I can find many discussions regarding dynamically adding
While many ask questions about where to find good books or tutorials, I'd like
There are many similar questions, but I didn't find one that gets straight to
I've tried my best to find out a solution with the many script questions
I seem to find many tutorials on how to work with two table, but
Was overwriting a TextView class, and as I didn't find many sources, I was
I find that many high level functions are missing in most well-known javascript libraries

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.