Reply to comment

How to handle auto rotation in UITabBarViewController based application

For TabView based application, there is many case that some of the view can be in landscape mode while other can't. In some cases, it is even complicated that one of the view in tab bar is navigation based and the view can only be in landscape mode after it is pushed to some view.

To handle this, it is very simple. Subclass you UITabBarViewController and overload this function:


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return [self.selectedViewController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}

Then the tab bar view controller will ask the current selected view controller for the orientation status. If the selected view controller is an navigation view controller, it will ask the current pushed view controller. So the orientation will be displayed correctly according the shouldAutorotateToInterfaceOrientation function of each view controller inside.

Note that this can only be good for application that complied for OS 3.0 or later. It is because that in OS 2.x, the auto rotation is badly implemented.

Reply

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.