Gaurav Taywade
Gaurav Taywade

Reputation: 8347

Resizing view controller acording to tabbar controller

In my application, I have developed one wizard in which I am providing a way for the user to setup his details one-by-one. After finishing all steps, the user will be redirected to the screen where TabBar will come into the picture.

The problem here is that the user can access the same view controllers with the wizard (without TabBar controllers) and normal flow (which is with tabbar controller). In the wizard, I am using a view controller of size 320x480 and the same in normal flow. But whenever I load any view controller using TabBar the 44 pixel view from bottom side gets hidden behind TabBar.

I know the I can manually set the view size, by detecting whether TabBar is present or not, but here in this case number of view controllers are more and its already designed of size 320x480.

I had tried with all methods given in Apple's documentation but none of it seems to work for me.

Following are the methods I have tried, along with some xib settings.

[self setWantsFullScreenLayout:YES];
self.view.autoresizingMask = UIViewAutoresizingFlexibleHeight;
[self.view setAutoresizesSubviews:YES];
[self.navigationController.view setNeedsLayout];

Is there any way to set the height of a view controller according to whether that TabBar is present or not?

Upvotes: 0

Views: 1501

Answers (3)

Michael Pirotte
Michael Pirotte

Reputation: 272

In my case, (Status bar/Nav bar/Hidden tabbar) this worked

//Add this in your ViewController
self.edgesForExtendedLayout = UIRectEdgeBottom;
self.extendedLayoutIncludesOpaqueBars = YES;

However Barry's answer is better if you use Storyboard but I could not for this VC. Tried for iOs7 and iOs 8.

Upvotes: 2

user246672
user246672

Reputation:

If you're using storyboards, select each tab VC and clear the box for View Controller > Extend Edges > Under Bottom Bars.

Upvotes: 0

arsenius
arsenius

Reputation: 13276

I wasn't able to find a good answer for this, so I ended up adding a BOOL, hasTabBar. I set it true or false based on where I create my view, and use that to calculate my layouts.

frame.size.height -= (hasTabBar*50); // works nicely.

Upvotes: -1

Related Questions