我在另一个导航 Controller 内的 View Controller 中添加了一个导航 Controller ...哈哈
无论如何,由于这种结构,我对推送到“子”导航 Controller 的任何 View 都有问题..因为它只适合“父”导航 Controller 的框架,它将推送的 View 内容向下推大约20/40像素...
我想知道如何阻止这种情况发生。这里有两张图片向您展示正在发生的事情。
标签明显位于界面构建器的中心
这是我到目前为止的代码。
- (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];
}
otherNav 也在 .h 文件中设置,以便在此 View 中进行全局访问。
最佳答案
当“ super ”NavigationBar可见时,self.view.frame.height为:
- 480-20-44 (actualViewheight-statusbarheight-navigationBarheight).
有 2 种解决方案可以解决您的问题。
1。为了简单起见,我会说,如果你唯一的问题是使其集中化。
[self.view addSubview:otherNav.view];
[otherNav.view setCenter:self.view.center];
这将使您的标签中心对齐。
2.不过,如果您使用的是界面生成器;
- select the xib file.
- select the view.
- open Utilities.
- set the Top bar as Navigation bar.
然后您将对齐的内容将与设备/模拟器或您正在测试的内容一样获得。
关于iphone - 使用位于另一个导航 Controller 内的导航 Controller 查看错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10844002/