Search code examples
iphoneobjective-ciosxcodecocoa-touch

View size reduces after hiding tab bar


In my iPhone app.

I am using UINavigationControllers in UITabBarController.

Like:

Tab Bar:

  • Navigation Controller.

    • View Controller1.
  • Navigation Controller.

    • View Controller2.

View Controllerx from any of above view controllers.

When I navigates to the View Controllerx.

I am hiding the tab bar.

The problem is that tab bar is hiding but view size reduces. And white space appears at bottom.

[self.tabBarController.tabBar setHidden:YES];
[self.tabBarController.tabBar setFrame:CGRectZero];
[self.navigationController pushViewController:obj_tipcalc animated:YES];
[obj_tipcalc release];

enter image description here

Thanks.


Solution

  • Your navigation controller's view lies within the view of your UITabBarController and it's not filling the entire screen. Simply try to resize it:

     ...
     CGRect biggerFrame = tabBarController.view.frame;
     biggerFrame.size.height += tabBarController.tabBar.frame.size.height;
     tabBarController.view.frame = biggerFrame ;
     ...
    

    To bring back the original layout:

    ...
    CGRect smallerFrame = tabBarController.view.frame;
    smallerFrame.size.height -= tabBarController.tabBar.frame.size.height;
    tabBarController.view.frame = smallerFrame;
    ...