tags:

views:

544

answers:

3

Hi guys,

How to rotate screen to landscape ?

Can you suggest simple code ?

Thanks in advance.

A: 

This howto describes how you can enable auto rotation in your application: http://developer.apple.com/iphone/library/codinghowtos/UserExperience/index.html#GENERAL-HANDLE_AUTOROTATION_OF_MY_USER_INTERFACE

This howto describes how you can start your application in landscape mode: http://developer.apple.com/iphone/library/codinghowtos/UserExperience/index.html#GENERAL-START_MY_APPLICATION_IN_LANDSCAPE_MODE

Lauri
A: 

It's trickier than you first think! After much discussion this blog post (with a link to further discussion afterwards) contains the cleanest answer:

How to Switch to Landscape Mode at will

buggles
A: 

in the uiViewController you should have the method

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

in order to rotate automatically.

If your app has an uiTabBarController then you have to subclass the UITabBarController and add the method to it also.Something like this:

@interface MyTabBarController : UITabBarController {

}

@end

#import "MyTabBarController.h"

@implementation MyTabBarController

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

@end
SorinA.