Search code examples
objective-ccocoa-touchipaduinavigationcontrolleruisplitviewcontroller

positioning problem with uisplitviewcontroller in left view


i got a little problem, when launching my splitview in landscape, there is a little black space above my left view controller: alt text

after rotating my ipad to portrait and switching back to landscape, the space is gone.

if i load the uitableviewcontroller directly into the left view, and not in a navigationcontroller, it works fine: alt text

any ideas why this is happening ??

// Produkte
    self.produkteMainTableVC = [[produkteMainTableViewController alloc] initWithStyle:UITableViewStylePlain];
    UINavigationController *produkteMainNavigationController = [[UINavigationController alloc] initWithRootViewController:self.produkteMainTableVC];
    self.produkteDetailVC = [[produkteDetailViewController alloc] initWithNibName:@"produkteDetailViewController" bundle:nil];
    self.produkteSplitVC = [[UISplitViewController alloc] init];

    self.produkteSplitVC.delegate = self.produkteDetailVC;
    self.produkteMainTableVC.produkteDetailVC = produkteDetailVC;
    [self.produkteSplitVC setViewControllers:[NSArray arrayWithObjects:produkteMainNavigationController,self.produkteDetailVC,nil]];

thanks for all help!

edit: its exactly 20px like the statusbar. does that help anyone?

edit2:

doing something like this:

if(self.navigationController.navigationBar.frame.origin.y >= 20.0) {

        self.navigationController.navigationBar.frame = CGRectMake(self.navigationController.navigationBar.frame.origin.x, 0.0, self.navigationController.navigationBar.frame.size.width, self.navigationController.navigationBar.frame.size.height);
    }

results that: alt text

a little improvement i would say. but i have no idea how to stick my tableview underneath the navigationbar.


Solution

  • UINavigationController has a nasty habit of shifting its contents down by 20px, depending where you place it. I'm guessing it's doing it here because your split view controller is inside of a tabbar controller, and Apple has not blessed this type of arrangement.