Reputation: 171
How would you change the height of the main view so that its height does not go beyond the tabbed navigation bar? I want the main view to be above the tabbed navigation bar.
Upvotes: 0
Views: 114
Reputation: 11855
I believe you want the content to not show up behind the navigation bar. If this is correct you can uncheck the Under Top Bars in your view controller.
You can try this with code
if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
self.edgesForExtendedLayout = UIRectEdgeNone;
you may also need to add
self.navigationController.navigationBar.translucent = NO;
The self.navigationController.navigationBar.translucent = NO;
should be all you need, however depending on your setup and what you are doing with the navigation bar you may need the additional code above.
You can add those into your viewDidLoad
or into viewDidLayoutSubviews
If that doesn't work you can try something like this if you need to support ios 6 as well.
- (void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
self.view.frame = CGRectMake(0,
self.topOfViewOffset,
self.view.frame.size.width,
self.view.frame.size.height);
}
Upvotes: 1
Reputation: 293
So if you have a content view that has a width as wide as your ViewController, that has an origin point of 0,0 (it's top left corner starts at the very top left hand corner of the view) and that has a navigation controller directly below it, I would do something like this in my ViewDidLoad method:
yourcontentview.frame = CGRectMake(0, //x co-ordinate
0, //y co-ordinate
self.view.frame.width, //set width as wide as the view's
self.view.frame.height - yournavigationbar.frame.height); //take the height of the nav controller away from the view and see what space is left.
or alternatively if your nav controller is NOT at the very bottom of your view change:
self.view.frame.height - yournavigationbar.frame.heigh
to
self.view.frame.heigh - yournavigationbar.frame.origin.y
The above ^ gets the start location of the nav controller in the view (so if it starts at 500 points down, then the height of the contentview will not go past 500 points)
Hope they work!
also if there is lots of content, you can always stick it in a scrollview :)
Upvotes: 0