弹出视图控制器导致条形按钮项目消失

Popping View Controller causes Bar Button Item to disappear

我的应用程序中有两个 ViewControllers。第一个ViewController(比如说,ViewController一个有一个Bar在 TableView (与问题无关) 中有幻灯片的按钮项。我在第二个ViewController中禁用了导航栏(比如,ViewControllerTwo 并添加了一个自定义视图和一个按钮。我已经编写了代码以在按钮的操作中弹出 ViewControllerTwo。但是一旦弹出,ViewControllerOne 中的 BarButton Item 就会消失。 这是我在 ViewControllerTwo

中编写的代码
[self.navigationController setNavigationBarHidden:YES animated:YES];

- (IBAction)backCustom:(id)sender 
{
   [self.navigationController popViewControllerAnimated:YES];
}

知道为什么 Bar Button Item 会因此消失吗?我确信这段代码是原因,因为当我删除它时,它在默认 NavigationBar 下运行良好。但我需要为我的项目自定义一个

在您的第一个 Viewcontroller 中添加以下行

-(void)viewWillAppear:(BOOL)animated{

[super viewWillAppear:animated];

[self.navigationController setNavigationBarHidden:NO animated:YES];
}