Reputation: 5510
I have added a navigation controller inside a viewcontroller thats inside another navigation controller... lol
well anyway because of this structure I have an issue with any views I push to the "sub"navigation controller.. because its only fitting inside the grame of the "parent" navigation controller its pushing the pushed views contents down by about 20/40pxl...
I was wondering how I get stop this from happening.. here are two pictures showing you what is happening.
where the label is clearly centered in Interface builder
This is the code I have so far for this stuff.
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
// Init the (sub)navigationController
otherNav = [[UINavigationController alloc] init];
// Add this (sub)NavController to the current viewcontroller (which is inside the (parent)navcontroller)
[self.view addSubview:otherNav.view];
// Hide the (sub)NavControllerbar
otherNav.navigationBar.hidden = YES;
// Load a detial view into the (sub)NavController
DetailViewController *detailView = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:[NSBundle mainBundle]];
[otherNav pushViewController:detailView animated:NO];
}
The otherNav is also set up in the .h file for global access in this view.
Upvotes: 0
Views: 150
Reputation: 4163
When the "super" NavigationBar is visible, the self.view.frame.height is:
- 480-20-44 (actualViewheight-statusbarheight-navigationBarheight).
There are 2 solutions for your problem.
[self.view addSubview:otherNav.view];
[otherNav.view setCenter:self.view.center];
This will make your label center alligned.
- select the xib file.
- select the view.
- open Utilities.
- set the Top bar as Navigation bar.
then the things you will align you will get as it is on device/simulator or what ever you are testing on.
Upvotes: 1