“返回”按钮未显示在导航项中
我遇到了一个非常微妙的问题。
通常一切都很好,但有时当前的 UIviewController 没有标题。当我调用另一个通过调用的视图控制器时,
[[fruitDB navigationController] pushViewController:fruitc animated:YES];
没有“后退”按钮。导航栏左上角的区域仍然处于活动状态,我可以返回。
即使没有标题,如何确保后退按钮仍然处于活动状态?
I came across a very subtle issue.
Usually things are okay, but occasionally the current UIviewController has no title. When I call another viewcontroller called via
[[fruitDB navigationController] pushViewController:fruitc animated:YES];
there is no "back" button. The area on the top left of the navigation bar is still active though and I can go back.
How can I make sure the back button is still active, even if there is no title?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以设置视图控制器的导航项的 backBarButtonItem。
具体来说,在推送 viewController2 之前,在 viewController1 中的某处执行以下操作...
当您推送 viewController2 时,显示的后退按钮将是 viewController1 的 backBarButtonItem。
注意:从技术上讲,苹果建议覆盖视图控制器中的 navigationItem 方法,并在其中添加按钮,但这对于您的情况来说确实不是问题。
you can set the backBarButtonItem of the navigation item of the view controller.
Specifically, somewhere in viewController1 before pushing viewController2, do the following...
When you push viewController2, the back button shown will be the backBarButtonItem of viewController1.
Note: Technically, apple recommends overriding the navigationItem method in your view controller, and adding buttons there, but it's really not an issue in your case.
在推送下一个视图控制器之前,为什么不尝试一下:
self.title = @"返回";
??Just before you push the next view controller why don't you try:
self.title = @"Back";
??