Search code examples
iphoneiosios-simulatoruiinterfaceorientationuidevice

How to change the orientation of the iDevice (iPad/iPhone)?


It is easy to change orientation of the iPad/iPhone simulators by following: hardware->rotate left or right. But, how can I change it on iDevice (iPad device or iPhone device?)

please can somebody help me?

should I add some code? enter image description here


Solution

  • Go to you summary tab, scroll down the to go "iPad Deployment Info". Unselect all the four options in "Supported Interface Orientations". Then select again, but select Portrait first and remaining after.

    enter image description here

    Also in View that you are expecting to be in portrait mode, just add

    - (NSUInteger)supportedInterfaceOrientations {
        return UIInterfaceOrientationMaskAll;
    }
    
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation
    {
        return (orientation == UIInterfaceOrientationMaskAll);
    }
    
    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
    {
        return UIInterfaceOrientationPortrait;
    }
    

    Hope this helps.