views:

655

answers:

1

I have a iPhone application that I am currently converting to a Universal Binary to work with the iPad. I have successfully implemented everything I need in terms of layout so that full landscape functionality is now supported in my app (previously I primarily used portrait mode to display content).

But, I have one strange problem, and it ONLY occurs in landscape mode: when I push a view controller onto the stack, it takes two taps on the back button to return to the previous view controller!!! The first tap shows a blank view, but with the same name on the left-side back navigation button, the second tap takes the controller back to previous view like it should.

I don't have an iPad to test, so I am relying on the simulator. The problem does not show up on the iPhone and doesn't show up if you rotate back to portrait mode.

My app consists of a tabbarcontroller with navigation controllers loaded for its vc's:

//application delegate
- (void)applicationDidFinishLaunching:(UIApplication *)application    
//....
WebHelpViewController *vc8 = [[WebHelpViewController alloc] init];
UINavigationController *nv8 = [[UINavigationController alloc] initWithRootViewController:vc8];

[self.tabBarController setViewControllers:[NSArray arrayWithObjects:nv1,nv2,nv3,nv4,nv5,nv6,nv7,nv8,nil]];

To implement landscape capability, the UITabBarController is overridden to autorotate when required:

//CustomTabBarController.m
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return [[(UINavigationController *)self.selectedViewController topViewController] shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}

... works fine. I navigate into new views using this method

SomeViewController *vc = [[SomeViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
[vc release];

Has anyone encountered this problem, and do they know if it's only a simulation error?

+8  A: 

Sounds like another ViewController is responding to - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

Check this first.

Cheers, Ken

Kenny
Thanks mate, that was the problem. I needed to make sure that all my ViewControllers implemented - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
David F
If you're using `CMD+N` to create new `UIViewControllers` in XCode, this method is one of the defaults included as part of the template.
Sneakyness
grrr I'm facing exactly the same kind of issue : I'm presenting a navigation controller as modal and then I push some ViewControllers. The navController and all pushed controllers return YES to shouldAutorotateToInterfaceOrientation but in landscape, I need to press "back" two times to get the navigation bar properly updated :/ any idea ?
yonel
hum, I didn't override this method for the default controller :/ that was causing the issue.
yonel