Jules
Jules

Reputation: 7766

iPhone, How do I force one view into landscape mode?

How do I force one view into landscape mode for a graph.

I want to click a tab bar button to make the graph view appear then when a button is clicked on that view I want to push a child screen which I need in portrait mode.

Once they click back i want to return to the graph view in landscape.

Upvotes: 4

Views: 2809

Answers (2)

Rog
Rog

Reputation: 17170

Use UIView's transform property to rotate it by PI radians:

-(void)viewWillAppear:(BOOL)animated
{
CGAffineTransform newTransform = CGAffineTransformMake(0.0,1.0,-1.0,0.0,0.0,0.0);         
self.view.transform = newTransform;

}

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIView_Class/UIView/UIView.html%23//apple_ref/doc/uid/TP40006816-CH3-SW4

Upvotes: 5

Bart Schoon
Bart Schoon

Reputation: 309

Maybe this will work for you

[[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationLandscapeLeft animated:NO];

or

[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeLeft];

Upvotes: 0

Related Questions