我需要引用 UINavigationBar
或 UINavigationItem
中的后退按钮。下图中的 Back
按钮。
我没有自定义按钮,因此
navigationItem.backBarButtonItem
navigationItem.leftBarButtonItem
这两个都是零。
有没有办法在不自定义按钮的情况下获取对按钮的引用?
引用:
更新:我的comment可能有助于理解为什么我不想自定义后退按钮。 :)
最佳答案
Documentation这是关于 backBarButtonItem 的:
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 default value is a button displaying the navigation item’s title.
所以 backBarButtonItem
默认总是 nil
因为它属于上一个 View Controller 。获得非零引用的唯一方法是自定义它。
但是,如果您只想更改名称,可以在以前的 View Controller 中完成。
关于ios - 引用 UINavigationBar 上的后退按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32076612/