为什么self.navigationItem.backBarButtonItem总是nil? [英] Why is self.navigationItem.backBarButtonItem always nil?

查看:272
本文介绍了为什么self.navigationItem.backBarButtonItem总是nil?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将一个视图控制器推到一个导航控制器,像这样:

I push a view controller onto a navigation controller like this:

[self.navigationController pushViewController:anotherViewController animated:YES];

然后,在 anotherViewController 中,检查self.navigationItem.BackBarButtonItem

And, then, inside anotherViewController I check self.navigationItem.BackBarButtonItem and LeftBarButtonItem, but they are always nil.

我可以看到backBarButtonItem,它似乎工作得很好。

I can see the backBarButtonItem, and it seems to work fine.

推荐答案

从文档:
当这个项目是导航栏的后面项目 - 当它是顶部项目下面的下一个项目时,它可以表示为按钮,使用此属性指定返回按钮,您设置的后栏按钮项目的目标和动作应为nil。默认值为显示导航项目标题的条形按钮项目。

From the Documentation: "When this item is the back item of the navigation bar—when it is the next item below the top item—it may be represented as a back button on the navigation bar. Use this property to specify the back button. The target and action of the back bar button item you set should be nil. The default value is a bar button item displaying the navigation item’s title."

我认为这是惯例它总是nil,默认值总是nil。

I'm taking this to mean that it is convention for it to always be nil, and that the default value is always nil.

讨论了关于self.navigationItem.backBarButtonItem为nil的类似主题:
更改UIBackButtonItem title

A similar subject about self.navigationItem.backBarButtonItem being nil was discussed here: Changing the UIBackButtonItem title

这篇关于为什么self.navigationItem.backBarButtonItem总是nil?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆