20

I have been unable to google an acceptable solution to this that can be applied to my project.

My app is a graphing tool that has three tabs; one for the graph itself and the other two are for browse/search functions for things that can be added to the graph. All tabs are navigation controllers.

The tab for the graph itself, when in portrait mode, displays a small preview of the graph and lists details of each entity that is on the graph below, and displays the tab bar at the bottom.

When the user rotates into landscape mode the graph turns full screen and everything else, including the tab bar, disappears. This is where I'm having the problem, as the GLView for my graph is always obscured by a white rectangle where the tab bar was.

I have tried changing the size of the navigation controllers view to full screen, changing the size of the tab bar controllers' view to full screen, changing the frame size of the tab bar itself to CGRect(0,0,0,0), becoming emotionally distraught, banging my fists on the desk, shouting abusive language at the MacBook, etc; all to no avail.

How can I make it work?

Tobster
  • 345
  • 1
  • 3
  • 12
  • Five years later, and still no decent solution that doesn't require hard-coding the rect? Did you ever figure this one out? Still an issue on iOS 9, apparently... – elsurudo Aug 03 '16 at 15:24
  • Btw, this is the best answer: http://stackoverflow.com/a/4242817/363789 – elsurudo Aug 03 '16 at 15:30

18 Answers18

34

I had this problem, and I've resolved it by changing tabbar's subview frame for my content view (there are 2 subviews in tab bar - content view (#0) and bar view (#1)):

[[self.tabBarController.view.subviews objectAtIndex:0] setFrame:FULLSCREEN_FRAME];
reqzix
  • 503
  • 1
  • 6
  • 12
6

I had the same problem and found the answer here : UIView doesn't resize to full screen when hiding the nav bar & tab bar

just resize the tabbarcontroller view this when you hide the tabbar :

tabBarController.view.frame = CGRectMake(0, 0, 320, 480);
Community
  • 1
  • 1
Thomas Joulin
  • 6,590
  • 9
  • 53
  • 88
3

It seems to have the problem with hiding the Bottom bar as Tab bar.... which I was facing and googled a lot for this.I consider it as a bug with this tab bar.Then also....we can use some trick.....

You can try for this and will definitely help if you are trying to hide the tab bar and which leaves the white space..

for the hell of coding you need to write just

[self setHidesBottomBarWhenPushed:YES];

when you are pushing to other view,where you don't need the Tab bar just write it

twitDetObj=[[TwitDetail alloc] initWithNibName:@"TwitDetail" bundle:nil];
[self.navigationController pushViewController:twitDetObj animated:YES];
self.hidesBottomBarWhenPushed=YES;
[twitDetObj release];

Hope this will work for you.....

CSchulz
  • 10,882
  • 11
  • 60
  • 114
Ajay Sharma
  • 4,509
  • 3
  • 32
  • 59
3

This one works for me:

[[self.tabBarController.view.subviews objectAtIndex:0] setFrame:CGRectMake(0, 0, 320, 480)];

I had this code within the tab's viewControllers.

Matt Chuang
  • 348
  • 3
  • 12
1

NOTE - This solution is to just to remove white space left after hiding tab bar.

For hiding tab bar best solution is - @Michael Campsall answer here

The simplest solution to this is to change your view's(in my case its tableView) bottom constraints, instead of giving bottom constraints with BottomLayoutGuide give it with superview. Screenshots attached for reference.

Constraints shown in below screenshots creates the problem, change it according to next screenshot

.enter image description here

Actual constraints to remove white space should be according to this(below) screenshot.

enter image description here

Community
  • 1
  • 1
Ajay Kumar
  • 1,807
  • 18
  • 27
1

For those who is still struggling with this. I have found that the problem lays on the constraints. Tab Bar is hidden, yet it already changed my constraint from Storyboard.

SWIFT 3+

self.tabBarController?.tabBar.isHidden = true

let cons = NSLayoutConstraint(item: textview, attribute: NSLayoutAttribute.bottom,
         relatedBy: NSLayoutRelation.equal, toItem: self.view, 
         attribute: NSLayoutAttribute.bottom, multiplier: 1.0, constant: 0)

view.addConstraints([cons])

In my case "textview" was the item, which supposed to fill the white space from hidden TabBar.

tataelm
  • 679
  • 8
  • 17
0

On after unhiding tababr and reaching to particular view. Tabbar was showing white space on above uitababr. This solved my problem

-(void)viewWillAppear:(BOOL)animated
{ 
    [[self.tabBarController.view.subviews objectAtIndex:0] setFrame:CGRectMake(0, 0, 320, 568)];

}
Saad Chaudhry
  • 1,392
  • 23
  • 37
DreamWatcher
  • 399
  • 1
  • 3
  • 11
0

Are you sure it's obscured and not just A) not redrawn or B) the frame of your GLView doesn't occupy that space?

Steven Canfield
  • 7,312
  • 5
  • 35
  • 28
  • I would say it more or less appears to not occupy the space rather than be obscured by it, however graph.superview.frame = CGRect(0,0,480,320) does not work, neither does the same with self.view, self.superview, just about any other combination. – Tobster Mar 11 '10 at 15:46
0

in the view pushed

- (BOOL)hidesBottomBarWhenPushed
{
    return YES;
}
fengd
  • 7,551
  • 3
  • 41
  • 44
0
- (void)hidesTabBar:(BOOL)hidden {
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0];

    for (UIView *view in self.tabBarController.view.subviews) {
        if ([view isKindOfClass:[UITabBar class]]) {
            if (hidden) {
                [view setFrame:CGRectMake(view.frame.origin.x, [UIScreen mainScreen].bounds.size.height, view.frame.size.width , view.frame.size.height)];
            } else {
                [view setFrame:CGRectMake(view.frame.origin.x, [UIScreen mainScreen].bounds.size.height - 49, view.frame.size.width, view.frame.size.height)];
            }
        } else {
            if([view isKindOfClass:NSClassFromString(@"UITransitionView")]) {
                if (hidden) {
                    [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, [UIScreen mainScreen].bounds.size.height)];
                } else {
                    [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, [UIScreen mainScreen].bounds.size.height - 49 )];
                }
            }
        }
    }

    [UIView commitAnimations];
}
Andy Lee
  • 143
  • 1
  • 8
0

My solution: set self.edgesForExtendedLayout = .None in your view controller's viewDidLoad().

Nejc
  • 123
  • 1
  • 9
0

some of the superviews of currentViewController.view of the tab bar view controller has clipToBounds set to YES (it's class name is UITransitionView, if not mistaken). To access it use

tabBarController.currentViewController.view.superview.superview.clipToBounds = NO;

after doing this your attempts of resizing a view will not be limited by anything and will succeed. Good luck!

Denis
  • 6,313
  • 1
  • 28
  • 27
0

This is just a workaround, but have you tried presenting the graph modally when the user rotates to landscape? This should obscure the tab bar.

You can avoid the transition with

[viewController presentModalViewController:graph animated:NO]

kevboh
  • 5,207
  • 5
  • 38
  • 54
0

its because the space where tab bar was , not allocated to other views when u set tab bar hidden u can set the corresponding view to stretch or fill the whole screen like scale fill or aspect fill something like that or take a view bigger than the iphine screen so that when u change the phone to landscape it can complete fill the screen

Pankaj Kainthla
  • 2,439
  • 5
  • 31
  • 61
0

Check the UIView underneath. It may be set to white, so when you hide the tab you're revealing the white UIView. Try setting the UIView to Transparent.

Ryan Garcia
  • 215
  • 2
  • 7
0

I think u need to set self.navigationController.view.frame to full size ie to UIApplication screen frame before u set tabbar hidden

Naveen Shan
  • 9,192
  • 3
  • 29
  • 43
-1

I'm assuming that you've already checked the autoresizing arrows on your view?

Owen Hartnett
  • 5,925
  • 2
  • 19
  • 35
-4

Have you tried hiding the UITabBar with

tab_bar.hidden = YES
Tuomas Pelkonen
  • 7,783
  • 2
  • 31
  • 32
  • That's what I'm doing to hide the tab bar, which successfully disappears; but leaves a white rectangle where it was. – Tobster Mar 11 '10 at 15:45