views:

110

answers:

0

I'm going nuts trying to see what I'm doing wrong with this...

  • I have an iPad app which runs only in landscape mode.
  • I have a UITabBarController which holds a webview:

    [tabBarController setViewControllers:
            [NSArray arrayWithObjects:browserController,
            nil] animated:YES];
    

I have a UIButton that I want to be able to use to switch from fullscreen (browserController) to tabBarController (and vice versa).

I tried the following, and the tab bar toggles, but the content is distorted (rotated 90 degrees) though the Tab Bar is properly placed (and rotates nicely). I have no idea why the web view is rotated to what looks like portrait mode.

When I try to toggle back to fullscreen after this, the webview rotates back to landscape (but shifts to the right).

All my view controllers override correctly shouldAutorotateToInterfaceOrientation:.

Can anyone please help?

S.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    // I start off Fullscreen
    [window addSubview:browserController.view];
    [window makeKeyAndVisible];

    return YES;
}

- (void) toggleTabBar {
if(!tabBarIsVisible){
    NSLog(@"Show TabBar");
    [browserController.view removeFromSuperview];
    [window addSubview:tabBarController.view];  
    [window makeKeyAndVisible];
    tabBarIsVisible = YES;  
}
else {
    NSLog(@"Hide TabBar");
    [tabBarController.view removeFromSuperview];
    [window addSubview:browserController.view];
    [window makeKeyAndVisible];
    tabBarIsVisible = NO;
}

}