简体   繁体   English

导航栏消失在popviewcontroller上

[英]Nav Bar disappearing on popviewcontroller

On one of my views, when a button is pressed I call another view that is a SplitViewController . 在我的一个视图中,当按下按钮时,我调用另一个是SplitViewController视图。 If this SplitViewController is called via one of these buttons I have special objects to add to the view. 如果通过其中一个按钮调用此SplitViewController ,我将有特殊对象添加到视图中。 mostly just nav bar items, like a cancel button. 主要是导航栏项目,如取消按钮。 This view can be accessed elsewhere and these items are not needed which is why there is the special condition. 这个视图可以在别处访问,不需要这些项目,这就是为什么有特殊条件。

However, when the user is done and i pop the ViewController back to the previous screen that was selected, the nav bar disappears on that screen. 但是,当用户完成并且我将ViewController弹回到选定的上一个屏幕时,导航栏将在该屏幕上消失。 I am not setting it to hidden nor am I doing anything strange with the nav bar. 我没有将它设置为隐藏,也不是我对导航栏做了什么奇怪的事情。 Simply adding the SplitViewController then popping back. 只需添加SplitViewController然后弹回。

Some code.. 一些代码..

//declare the split screen VC
SplitScreenViewController *split = [[SplitScreenViewController alloc] init];

//set the flag that this VC is coming from a button, so we need the extra nav bar items
[split setIsFromButton:YES];
[self.navigationController pushViewController:split animated:YES];

now the call back is simply... 现在回电只是......

- (void)cancelSelectionBtnClicked
{
     [self.navigationController popViewControllerAnimated:YES];
}

and when the view returns, the nav bar is gone. 当视图返回时,导航栏消失。

any ideas? 有任何想法吗?

edit it should be noted this exact same thing is done elsewhere the same way(as far as I can tell) and the nav bar is visible on return. 编辑它应该注意这完全相同的事情在其他地方以相同的方式完成(据我所知)并且导航栏在返回时可见。

In your ViewController's viewWillAppear you can again make your navigationBar visible. 在ViewController的viewWillAppear您可以再次使navigationBar可见。

- (void)viewWillAppear:(BOOL)animated
{
    [self.navigationController setNavigationBarHidden:NO];
}

我在UISplitViewController中看到了各种奇怪的导航栏行为,在少数情况下,这是因为控制器没有设置为窗口的rootViewController而不是像你设置的导航控制器内部。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM