Ios 在ChildViewController上添加导航栏

Ios 在ChildViewController上添加导航栏,ios,iphone,ios7,uinavigationbar,childviewcontroller,Ios,Iphone,Ios7,Uinavigationbar,Childviewcontroller,我想要一个新的视图控制器作为弹出窗口,其中有一些父视图控制器场景。所以我决定添加childViewController,它从四面都有50px的透明边框。现在,当我添加childViewController时,我没有得到navigationBar。这就是我添加全尺寸childViewController的方式 ShowPostTVC *postvcObj = [self.storyboard instantiateViewControllerWithIdentifier:@"ShowPos

我想要一个新的视图控制器作为弹出窗口,其中有一些父视图控制器场景。所以我决定添加childViewController,它从四面都有50px的透明边框。现在,当我添加childViewController时,我没有得到navigationBar。这就是我添加全尺寸childViewController的方式

    ShowPostTVC *postvcObj = [self.storyboard instantiateViewControllerWithIdentifier:@"ShowPostTVC"];

    UINavigationController *childNavController = [[UINavigationController alloc] initWithRootViewController:postvcObj];
  [self.navigationController addChildViewController:childNavController];
  [self.navigationController.view addSubview:postvcObj.view];
  [postvcObj didMoveToParentViewController:self];

如何在childViewController上获得真正的导航栏。

显示新ViewController的正确方法是通过UINavigationController的pushViewController:animated。然后,新的ViewController有一个导航栏:

    ShowPostTVC *postvcObj = [self.storyboard instantiateViewControllerWithIdentifier:@"ShowPostTVC"];

    UINavigationController *childNavController = [[UINavigationController alloc] initWithRootViewController:postvcObj];
  [self.navigationController addChildViewController:childNavController];
  [self.navigationController.view addSubview:postvcObj.view];
  [postvcObj didMoveToParentViewController:self];
ShowPostTVC *postvcObj = [self.storyboard instantiateViewControllerWithIdentifier:@"ShowPostTVC"];
[self.navigationController pushViewController:postvcObj animated:true]; 

不要实例化新的UINavigationController,只需使用以下命令:

ShowPostTVC *postvcObj = [self.storyboard instantiateViewControllerWithIdentifier:@"ShowPostTVC"];
[self.navigationController pushViewController:postvcObj];

现在能用了吗?还有其他问题吗