Search code examples
iphoneipadrotationxcode4.5uiinterfaceorientation

One View Controller Portrait, The Other Landscape


I have the initial view controller that is portrait, and I want the next view controller to only be landscape. The user can't turn the iPhone/iPad to change rotation. Can someone please help me with this?

Any help appreciated.


Solution

  • I think what you want is : shouldAutoRotateToInterfaceOrientation method of UIViewController Class.

    This function returns YES if the orientations is supported by your UIView. If you return YES only to the landscape orientation, then the iPhone will automatically be put in that orientation.

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
        // Return YES for supported orientations
        return (interfaceOrientation == UIInterfaceOrientationLandscape);
    }
    

    GoodLuck !!!