views:

115

answers:

3

My app has 4 tabs. All the view controllers support rotation, and indeed are rotated when I rotate the device. For one of the view controllers, I need to reposition some of the subviews upon rotation. I do this in willRotateToInterfaceOrientation of that view controller, and it works fine.

The problem comes when I switch to a different tab, then rotate the device, then go back to the original tab. It apparently has not received the rotation notification, since willRotateToInterfaceOrientation has not been called. So it seems as though only the "active" view controller gets notified that the device has rotated.

The question: how do you get all the view controllers (controlled by a TabBarController) to rotate?

A: 

Unfortunately this is a bug in iOS 3.x. It works fine in iOS 4.x. I've seen apps that manually keep track of orientation changes and then do the rotation manually for inactive viewcontrollers. Sucks.

St3fan
Hmm. This is an iPad app, so I'm testing on iPad simulator 3.2. You're saying that once I can build with iPad 4.0 it will magically start working?
sol
It will presumably work for iPads on 4.0+; users who haven't upgraded will of course still get the bug.
tc.
A: 

Looking through the iOS 3.2 docs to make sure this works, there is a viewControllers property in UITabBarController. Try something like this:

for (UIViewController * viewController in tabBarController) {
    // Do stuff here with each 'viewController'.
}

I recommend that you do something with the UIViewController's -shouldAutorotateToInterfaceOrientation: method but you may have another way in which you plan on achieving the rotation.

Alexsander Akers
A: 

You should also check for the interface orientation in viewWillAppear method of the controller whose subviews frame you are changing.Because when you move to the new tab and rotate the device and now when you tap another tab the viewWillAppear method will we called and there you can change the frames accordingly. I also faced the same problem which i sorted out using this approach

anurag