Rotation on certain screens

4

How do I set only a UIViewController to be enabled in rotation?

The scenario is as follows:

  

I have 5 screens, and in all of them I should only enable the mode   portrait. But I have a sixth screen, and it must be enabled   the landscape modes.

Note: Currently the settings in my project are only to accept portrait mode.

    
asked by anonymous 16.12.2014 / 17:27

3 answers

1

Do the following:

Create a project in Xcode 6.1.1 with the Tabbed Application template as it is faster to develop and demonstrate functionality. I've done in Swift but should be the same in Objective-C

You will have Tab Bar Controller and two related views: FirstViewController and SecondViewController

In one of the views ( FirstViewController for example) do as in the figure below. The other leave everything in Default (Orientation: inferred, etc.). For min only fixed Portrait orientation worked in View% with% when I unselected FirstView .

That'sit!Itworks:onlyResizeviewfromNIBhasfixedorientation.TheFirstViewallowsthechangeoforientationtosuitthenewdimensions.

  

Youcandownloadtheprojectat link .

    
22.12.2014 / 00:48
0
  • Enable in the project settings all the guidelines that you will need. (In your case enable everything, I understand.)
  • In all UIViewController 's of your project implement the supportedInterfaceOrientations method by returning the desired setting.

    Example in controller that will support all returns UIInterfaceOrientationMaskAll in others returns UIInterfaceOrientationMaskPortrait

  • If you are using Storyboard leave everything marked as inferred on Simulated Metrics
  • 23.04.2015 / 16:03
    -2

    Hello, in AppDelegate.h add

    @property (nonatomic , assign) bool blockRotation;
    

    and in AppDelegate.m

    -(NSUInteger)application:(UIApplication *)application       supportedInterfaceOrientationsForWindow:(UIWindow *)window
    {
    if (self.blockRotation) {
        return UIInterfaceOrientationMaskPortrait;
    }
    return UIInterfaceOrientationMaskAll;
    }
    

    And in the views you want to disable rotation, just add

    - (void)viewDidLoad
    {
     [super viewDidLoad];
        AppDelegate* shared=[UIApplication sharedApplication].delegate;
        shared.allowRotation=YES;
    }
    
    -(void)viewWillDisappear:(BOOL)animated{
      AppDelegate* shared=[UIApplication sharedApplication].delegate;
      shared.allowRotation=NO;
    
      }
    

    Another way is to add in each view the

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        if(interfaceOrientation == UIInterfaceOrientationPortrait)
            return YES;
    
        return NO;
    }
    

    Source: link

        
    16.12.2014 / 17:53