如何隐藏导航栏的标题保持后退按钮

时间:2020-12-29 22:49:10

How can I hide the title of the nav bar but keep the back button with the word "Back" on it? I noticed that in objective-c when I don't set a title for the navigation controller, the back button does not show up. I would like to hide the title (because I use a custom background), and keep the back button with the word "Back".

如何隐藏导航栏的标题,但保留后退按钮上有“后退”字样?我注意到在objective-c中,当我没有为导航控制器设置标题时,后退按钮不显示。我想隐藏标题(因为我使用自定义背景),并保持后退按钮的单词“后退”。

1 个解决方案

#1


1  

The title of the back button is set on the navigation item of the view controller that is pushed onto the stack before the current one, not on the navigation item of the current controller. This is somewhat non-intuitive.

后退按钮的标题设置在视图控制器的导航项上,该导航项在当前控制器之前被推到堆栈上,而不是在当前控制器的导航项上。这有点不直观。

In the interface builder go to the view to which the back button leads, select its navigation item or add a new one, go to the "Back" button property, and enter the text that you would like to appear on the back button. Now go to the controller where you would like to have no title, and erase the text in the "Title" property of its navigation item.

在界面构建器中,转到后退按钮所在的视图,选择其导航项或添加新项,转到“后退”按钮属性,然后输入要在后退按钮上显示的文本。现在转到您想要没有标题的控制器,并删除其导航项的“标题”属性中的文本。

#1


1  

The title of the back button is set on the navigation item of the view controller that is pushed onto the stack before the current one, not on the navigation item of the current controller. This is somewhat non-intuitive.

后退按钮的标题设置在视图控制器的导航项上,该导航项在当前控制器之前被推到堆栈上,而不是在当前控制器的导航项上。这有点不直观。

In the interface builder go to the view to which the back button leads, select its navigation item or add a new one, go to the "Back" button property, and enter the text that you would like to appear on the back button. Now go to the controller where you would like to have no title, and erase the text in the "Title" property of its navigation item.

在界面构建器中,转到后退按钮所在的视图,选择其导航项或添加新项,转到“后退”按钮属性,然后输入要在后退按钮上显示的文本。现在转到您想要没有标题的控制器,并删除其导航项的“标题”属性中的文本。