views:

971

answers:

2

Hello,

I have MainWindow.xib in the application.

In the Interface Builder, I rotate the main window from portrait to landscape and than put few UIControls on it.

Than I save it.

After that when I run the application although during design time I made everything in landscape mode, it always displays things in portrait mode.

Please help me

+1  A: 

IB just sets up your XIB files. It's your view controller that manages the orientation.

The default UIViewController or UINavigation controller has details on this.

Specifically, you need to overload

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

Have a look at the documentation for UIViewController for more info.

Jessedc
+1  A: 

In addition to overriding shouldAutorotate to say what orientations you support, you should also set the "initial interface orientation" key in your info.plist file to set your preferred initial orientation.

For more information, search for "Launching in Landscape Mode" in the iPhone Application Programming Guide.

David Maymudes