问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

如何令BackBarButtonItem只有箭头,而没有文本

发布网友 发布时间:2022-05-23 03:37

我来回答

2个回答

热心网友 时间:2023-09-18 11:08

  首先我们得了解一下

  backBarButtonItem

  leftBarButtonItem

  rightBarButtonItem

  他们都属于UINavigationItem的组成部分,都显示在navigationBar上,都属于UIBarButtonItem类

  backBarButtonItem和另外两兄弟是有区别的

  比如当前有AController准备push到BController,设置backBarButtonItem的title和image需要在AController内设置,在调用AController Push:B之前进行设置,AController.navigationItem.backBarButtonItem = ....

  而其他两兄弟则是在BController的ViewDidload后设置均可.

  backBarButtonItem的描述

  Discussion

  When this navigation item is immediately below the top item in the stack, the navigation controller derives the back button for the navigation bar from this navigation item. When this property is nil, the navigation item uses the value in its title property to create an appropriate back button. If you want to specify a custom image or title for the back button, you can assign a custom bar button item (with your custom title or image) to this property instead. When configuring your bar button item, do not assign a custom view to it; the navigation item ignores custom views in the back bar button anyway.

  说明了backBarButtonItem只能自定义image和title,不能重写target or action,系统会忽略其他的相关设置项。
  如果硬是需要重写action做一些其他的工作,则需要自定义一个leftBarButtonItem,因为系统定义leftBarButtonItem的显示优先级比backBarButtonItem优先级高,当存在leftBarButtonItem时,自动忽略backBarButtonItem,达到重写backBarButtonItem的目的。

  2、各个对象下的backBarButtonItem的区别
  对于这3兄弟,在3个类下面都能发现他们

  比如当前在一个UIViewController内,输入以下方法都能发现他们。(同leftBarButtonItem | rightBarButtonItem)

  self.navigationItem.backBarButtonItem

  self.navigationController.navigationItem.backBarButtonItem

  self.navigationController.navigationBar.backItem.backBarButtonItem

  比如在AController->BController,在A设置了self.navigationItem.backBarButtonItem,经过试验发现,这个backBarButtonItem为BController的self.navigationController.navigationBar.backItem.backBarButtonItem。

  UIViewController的属性navigationItem正是被当前UINavigationBar--[UINavigationBar appearance]管理的属性

  
  @property(nonatomic, readonly, retain)UINavigationItem *navigationItem The navigation item used to represent the view controller in a parent’s navigation bar. (read-only)
  

  self.navigationController.navigationItem.backBarButtonItem

  则是表示当前navigationController的parent的UINavigationBar,一般情况下没有这样的嵌套。

热心网友 时间:2023-09-18 11:08

首先了解一下

  backBarButtonItem

  leftBarButtonItem

  rightBarButtonItem

  他们都属于UINavigationItem的组成部分,都显示在navigationBar上,都属于UIBarButtonItem类

  backBarButtonItem和另外两兄弟是有区别的

  比如当前有AController准备push到BController,设置backBarButtonItem的title和image需要在AController内设置,在调用AController Push:B之前进行设置,AController.navigationItem.backBarButtonItem = ....

  而其他两兄弟则是在BController的ViewDidload后设置均可.

  backBarButtonItem的描述

  Discussion

  When this navigation item is immediately below the top item in the stack, the navigation controller derives the back button for the navigation bar from this navigation item. When this property is nil, the navigation item uses the value in its title property to create an appropriate back button. If you want to specify a custom image or title for the back button, you can assign a custom bar button item (with your custom title or image) to this property instead. When configuring your bar button item, do not assign a custom view to it; the navigation item ignores custom views in the back bar button anyway.

  说明了backBarButtonItem只能自定义image和title,不能重写target or action,系统会忽略其他的相关设置项。
  如果硬是需要重写action做一些其他的工作,则需要自定义一个leftBarButtonItem,因为系统定义leftBarButtonItem的显示优先级比backBarButtonItem优先级高,当存在leftBarButtonItem时,自动忽略backBarButtonItem,达到重写backBarButtonItem的目的。

  2、各个对象下的backBarButtonItem的区别
  对于这3兄弟,在3个类下面都能发现他们

  比如当前在一个UIViewController内,输入以下方法都能发现他们。(同leftBarButtonItem | rightBarButtonItem)

  self.navigationItem.backBarButtonItem

  self.navigationController.navigationItem.backBarButtonItem

  self.navigationController.navigationBar.backItem.backBarButtonItem

  比如在AController->BController,在A设置了self.navigationItem.backBarButtonItem,经过试验发现,这个backBarButtonItem为BController的self.navigationController.navigationBar.backItem.backBarButtonItem。

  UIViewController的属性navigationItem正是被当前UINavigationBar--[UINavigationBar appearance]管理的属性

  
  property(nonatomic, readonly, retain)UINavigationItem *navigationItem The navigation item used to represent the view controller in a parent’s navigation bar. (read-only)
  

  self.navigationController.navigationItem.backBarButtonItem

  则是表示当前navigationController的parent的UINavigationBar,一般情况下没有这样的嵌套。
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
春水的诗句有哪些(描写春水的好词好句) 关于春水的诗句有哪些? 描写春水的词句 形容春水的诗句有哪些 请问不联网怎么用电脑拍照呀,东芝 win7家庭普通版的? win7内置摄像头怎么打开啊,是东芝L600D 536的,问了一下卖电脑那里,她说... 东芝笔记本windows7怎么开视频 东芝笔记本windows7开视频方法 tn6破解器tn6怎么使用? 金银首饰及一些制品是机器雕刻的还是模板印的。 ospod行业模版分类 ...红色、黑色还要什么颜色,都是放什么垃圾的,记不太清了 固安大众点评推广多少钱 三菱plc的记数器怎么显示触摸屏编程 uinavigationcontroller不设置根控制器能显示东西吗,我建了一个AddressViewController,h和.m文件,还有 如何隐藏UIBarButtonItem按钮 西门子触摸屏怎么显示出计数器的历史数据 EXCEL 不能打印 换个打印机或者换 怎么把PLC程序的定时器与计时器时间与计数功能显示到触摸屏上请大神帮 有个片段讲一个士兵一直往后方背伤员,连敌军也背回去,放成一排 画色彩时应该多用白么? 怎么在触摸屏上显示计数,我用的是omron PLC 跟威纶触摸屏 二战时美国一个医务兵救了七十多人叫什么? 大众点评网开店要收佣金吗 昆仑通态触摸屏显示计数器数值,例如瓶子个数,PLC是西门子200的 西方用白色代表纯洁,中国古代却为什么选择白色作为戴孝的颜色呢? 血战钢锯岭这部电影里面的大兵为什么不爬上山去帮忙救受伤的战友,反而在下面躲着呢? 山水点歌机蓝牙如何使用 一个真实故事改编的电影。男主角在战争里救了很多人是什么电影? 如何在ToolBar隐藏BarButtonItem 《血战钢锯岭》仅仅只是主角徒手打赢一场救人战争,为什么这么牛 ios设置界面右上角的按钮怎么添加 如何设置leftBarButtonItem左对齐 如何修改navigationItem的rightBarButtonItem 背景颜色 如何调整导航条上的leftBarButtonItem和rightBarButtonItem的位置 高数计数器编的程序如何在触摸屏上显示 点歌机如何连接? 为什么我的UIBarButtonItem点击没有反应 大众点评合作收费标准 三菱FX2N PLC,中的计数器怎么用法?能不能在触摸屏上显示数值呀? sony的navigation controller有什么用 IOS 中navigationItem中的title如何实现被点击 如何在navigationcontroller中间设置个按钮 ios 导航栏不能使用dismissviewcontrolleranimated方法吗 威纶通 台达PLC计数器怎样才能把台达计数器C的值在触摸屏里面显示出来呀 家用点歌机可以加装蓝牙发射功能吗? 如何将PLC里计数器的设定值和每加1的当前值在触摸屏上显示出来呢 龙族4主要讲什么啊 点歌机是否能安装蓝牙软件? 龙族4奥丁之渊什么意思 龙族4奥丁之渊章节之如何评价龙族4奥丁之渊4 关于龙族4奥丁之渊