Question

I make an application using Tab Bar. I have 2 views controller: View1 and View2 and a RootViewController. In RootViewController.m:

- (void)viewDidLoad
{
    [self.navigationItem setTitle:@"Tab Bar"];
    View1 *vc1 = [[View1 alloc]init];
    View2 *vc2 = [[View2 alloc]init];

    [vc1.tabBarItem setTitle:@"View1"];
    [vc2.tabBarItem setTitle:@"View2"];

    [self setViewControllers:[NSArray arrayWithObjects:vc1, vc2, nil]];
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

When I build application, I have an error: Have a white place. When I go to View 2 and back to View 1 it is disappeared. I want to delete white place. Please see image in here: http://photo.ssc.vn/images/108Screen_Shot_2013_08_18.jpg Thanks for your helping!

enter image description here

Was it helpful?

Solution

This is a common issue when adding view controllers to a tab bar.

The solution is to set wantsFullScreenLayout on the UINavigationController to NO, so it won't even attempt to leave that gap for the status bar.

Apple says :

Tab bar controllers support full-screen layout differently from the way most other controllers support it. You can still set the wantsFullScreenLayout property of your custom view controller to YES if you want its view to underlap the status bar or a navigation bar (if present). However, setting this property to YES does not cause the view to underlap the tab bar view. The tab bar controller always resizes your view to prevent it from underlapping the tab bar.

For more detailed explanation you can see this Question.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top