views:

43

answers:

2

I have an application with the a sructure as follows

  • UITabBarController (3 tabs)
    • UINavigationController (in each of the tabs)
      • UIViewController (in each of the Navigation controllers)

In it I want some of the UIviewControllers to be able to switch to both landscape and potrait modes

for example In Tab 2 I have a Picture Gallery section (View 1) In it I have 9 Buttons for 9 Picture galleries When button 1 is touched the Navigation controller navigates to View 2 where users are able to browse through different photos. When the User touches a photo It Navigation controller navigates to View 3 for a full screen mode.

Now I want View 3 to be orientable to both Landscape and portrait mode. where as all previous views should only be viewed in portrait mode. How do i go about doing this?

I have already fiddled around with the

(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

method in all the views but I just cant seem to get it right.

A: 

I had hard time with this situation.

2 ways to solve this :

1st
Use [[UIDevice currentDevice] setOrientation:whatever]; It will trigger a warning.

2nd
Use presentModalViewController:animated: And implement shouldAutorotateToInterfaceOrientation: in this Modal View Controller. If you want to keep the original transition animation you will have to code a bit though.

Benj
could you elaborate a bit more?
Rupert
A: 

The root view controller (UITabBarController) in this case has to implement shouldAutorotateToOrientation: and then so does each child controller. so set the tab bar controller's method to YES, then for the ones you don't want anything but portrait just set it to return yes only for that view and etc.

Jesse Naugher
that doesn't seem to work properly. the orientation happens in all the views
Rupert