iOS
iOS

Reputation: 3616

Disable portrait mode

I am developing an iPhone application and the application should work only in landscape mode. But, when I rotate the device or simulator, the viewContoller's mode changes from landscape to portrait. I want the viewController to maintain in landscape mode, though the device or simulator is portrait. How could I make this happen? Thanks in advance.

Upvotes: 0

Views: 1719

Answers (4)

Hiren
Hiren

Reputation: 12780

Add this to your ViewController.m

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
        return UIInterfaceOrientationIsLandscape(interfaceOrientation);   
}

Upvotes: 1

Muhammed Ayaz
Muhammed Ayaz

Reputation: 1398

change in info_plist .. Supported interface orientations Set only landscape

Upvotes: 0

rockeye
rockeye

Reputation: 2773

Override this method in your view controller:

// Override to allow orientations other than the default portrait orientation.
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientation, NO for other;
}

Upvotes: 1

Léon Rodenburg
Léon Rodenburg

Reputation: 4894

Override this method in all your ViewControllers:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight ||
            interfaceOrientation == UIInterfaceOrientationLandscapeLeft);

}

And also see Only support for landscape Interface orientation

Upvotes: -1

Related Questions