iPhone Alternate View for Landscape Mode on Rotation

722 Views Asked by At

I'm looking to have an alternate view for one of my ViewControllers when the user rotates the device to landscape (think CoverFlow in iPod) I have implemented this using the AlternateViews sample code (listening for a device rotation notification).

However, I've noticed a bug. I have a rather complicated UI - TabViewController/UINavigationController. When on one ViewController that uses the AlternateViews code and switch to another tab that also has an AlternateView the notifications seem to compete. Meaning it will show the AlternateView, but the one for the first tab's view controller not the second. If I back out of the navigation hierarchy so only one AlternateView exists, then it's fine.

In the end, I don't need an entirely separate ViewController for landscape mode. In fact, this is actually making things more complicated as I need it to have the same navigation bar and IBActions. What I need is to load in a UIWebView on device rotation (if not already loaded) and hide the current view (UITableView). This would also alleviate the bug above.

I can setup the code to create/show/hide the UIWebView and UITableView. However, I don't know exactly where or when to do that - willAutoRotateToOrientation? Any reference to the delegate method and psuedo code would be greatly appreciated.

Of course, if anyone has a fix for the AlternateViews sample code, given my UI hierarchy, I would appreciate that as well.

1

There are 1 best solutions below

1
On

I would recommend putting your code that swaps out the views into -didAnimateFirstHalfOfRotationToInterfaceOrientation:

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/Reference/Reference.html

That way, your existing view starts to visibly rotate, then the new view gets swapped in and completes the rotation.