Setting View to Landscape and Hiding Status Bar in iPhone

If you were wondering how to start your application in landscape mode with the status bar hidden, you need to override two methods in your ViewController: viewDidLoad and shouldAutorotateToInterfaceOrientation.


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];
[super viewDidLoad];
}

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

Tags:

Leave a Reply