iphone - 使用位于另一个导航 Controller 内的导航 Controller 查看错误

标签 iphone ios uiviewcontroller uinavigationcontroller

我在另一个导航 Controller 内的 View Controller 中添加了一个导航 Controller ...哈哈

无论如何,由于这种结构,我对推送到“子”导航 Controller 的任何 View 都有问题..因为它只适合“父”导航 Controller 的框架,它将推送的 View 内容向下推大约20/40像素...

我想知道如何阻止这种情况发生。这里有两张图片向您展示正在发生的事情。

enter image description here

标签明显位于界面构建器的中心

enter image description here

这是我到目前为止的代码。

- (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.不过,如果您使用的是界面生成器;

  1. select the xib file.
  2. select the view.
  3. open Utilities.
  4. set the Top bar as Navigation bar.

然后您将对齐的内容将与设备/模拟器或您正在测试的内容一样获得。

关于iphone - 使用位于另一个导航 Controller 内的导航 Controller 查看错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10844002/

相关文章:

ios - iphone 4.0 以编程方式发送短信

iPhone app 类似 Twitter 的设计结构

ios - 关闭 View Controller 时出错

iphone - 如何旋转和调整 Sprite 像库中的照片大小

c# - 如何向 50 个用户发送推送通知

ios - 将用户输入的文本传递给后续的 segue

ios - 在Swift中将逗号和十进制后的零值添加到千位数后的字符串中

ios - Xcode点击手势导致错误

iphone - SKStoreproductviewcontroller 在横向模式下被截断

iphone - 阻止用户以横向方式查看某些 View