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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:40:29+00:00 2026-06-16T04:40:29+00:00

I have a master view controller that’s inside a UINavigationController. In that master view

  • 0

I have a master view controller that’s inside a UINavigationController. In that master view controller, I have a button that pushes a detail view controller that has a UIWebView inside of it. I want this detail view controller to be on landscape mode when it’s loaded. Going back to the master view controller, it forcibly goes back again to portrait mode. I’m running iOS 6 on this.

I have seen the other similar questions but it’s not working on my end. I have created a LandscapeViewController that’s a subclass of UIViewController where I have written these methods:

#pragma mark - Orientation Methods
- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
}

- (BOOL)shouldAutorotate
{
    return YES;
}

This is my code when I push the detail view controller:

DetailViewController *detailVC = [[DetailViewController alloc]
                                      initWithNibName:@"DetailViewController"
                                      bundle:nil];

    [self.navigationController pushViewController:detailVC
                                         animated:YES];

I’m thinking on where to subclass my LandscapeViewController on the code above to make it work or on how to properly subclass and push my detail view controller. I can also present my detail view controller modally if it’s not possible for the navigation controller to push my detail view controller from portrait to landscape. Where am I doing it wrong?

  • 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-16T04:40:30+00:00Added an answer on June 16, 2026 at 4:40 am

    Considering:
    View A: Portrait only – View B: Landscape only

    I couldn’t do it in the navigation controller. Instead what I did was to open a modal view from view A to view B and force a new navigation controller into this view.

    This is working for me in iOS5+.

    You need to create a category for the navigation controller like this:

    UINavigationController+Rotation_IOS6.h

    #import <UIKit/UIKit.h> 
    
    @interface UINavigationController (Rotation_IOS6)
    
    - (BOOL)shouldAutorotate;
    - (NSUInteger)supportedInterfaceOrientations;
    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation;
    
    @end
    

    UINavigationController+Rotation_IOS6.h

    #import "UINavigationController+Rotation_IOS6.h"
    
    @implementation UINavigationController (Rotation_IOS6)
    
    - (BOOL)shouldAutorotate
    {
        return [self.topViewController shouldAutorotate];
    }
    
    - (NSUInteger)supportedInterfaceOrientations
    {
        return [self.topViewController supportedInterfaceOrientations];
    }
    
    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
    {
        return [self.topViewController preferredInterfaceOrientationForPresentation];
    }
    
    @end
    

    In AppDelegate.m add:

    - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
        return UIInterfaceOrientationMaskAll;
    }
    

    Then in View A:

    - (BOOL)shouldAutorotate {
        return YES;
    }
    
    -(NSUInteger)supportedInterfaceOrientations
    {
        return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
    }
    
    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
    {
        return UIInterfaceOrientationPortrait;
    }
    
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        return (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
    }
    

    also in View A to open View B do this:

    ViewB *vc = [[ViewB alloc] initWithNibName:@"ViewB" bundle:nil];
    
    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:vc];
    
    [self presentViewController:navigationController animated:YES completion:nil];
    

    And, finally, in View B

    - (BOOL)shouldAutorotate {
        return YES;
    }
    
    -(NSUInteger)supportedInterfaceOrientations
    {
        return UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskLandscapeLeft;
    }
    
    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
    {
        return UIInterfaceOrientationLandscapeRight;
    }
    
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a splitViewController that has a master and detail view controllers. The code
I have a controller's action and view page that uses a master page. The
I have a master detail Application in xCode. In Master View Controller an Array
When using a spilt view controller, I have a Master and Detail View. When
I have a split view-based app that presents a master-detail interface, and uses a
How can I detect back in my mapview (master) controller that the detail view
I have created on Split view controller which has master view on left side
I have a modal view controller and a master view controller. When I open
I have a tab bar controller in the master view of a split view
I have a UISplitViewController with the master view set up like this: UITabBarController Tab1:

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.