Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UIBarButtonItem-使其在仅显示文本时不可单击_Ios_Objective C_Uibarbuttonitem_Uitoolbar - Fatal编程技术网

Ios UIBarButtonItem-使其在仅显示文本时不可单击

Ios UIBarButtonItem-使其在仅显示文本时不可单击,ios,objective-c,uibarbuttonitem,uitoolbar,Ios,Objective C,Uibarbuttonitem,Uitoolbar,所以我有一个UIToolbar,上面有4个UIBarButtonims(其中2个是灵活的空间),中间一个是样式:带有标题集“设置”的普通按钮,然后最右边的按钮是“完成”按钮,用于关闭视图 除了中间的文本按钮是“可点击的”之外,所有的东西看起来都很好,并且按照我想要的方式工作。当你点击它时,它什么都不做,但是一旦触摸到它,文本周围就会出现一道白光 UIBarButtonItem的唯一选项是“启用”,如果禁用该选项,将使文本变灰 通过创建UILabel并将其作为子视图添加到UIToolbar,我几乎

所以我有一个UIToolbar,上面有4个UIBarButtonims(其中2个是灵活的空间),中间一个是样式:带有标题集“设置”的普通按钮,然后最右边的按钮是“完成”按钮,用于关闭视图

除了中间的文本按钮是“可点击的”之外,所有的东西看起来都很好,并且按照我想要的方式工作。当你点击它时,它什么都不做,但是一旦触摸到它,文本周围就会出现一道白光

UIBarButtonItem的唯一选项是“启用”,如果禁用该选项,将使文本变灰

通过创建UILabel并将其作为子视图添加到UIToolbar,我几乎可以模拟它的外观,但我想知道是否有更简单的方法来实现这一点


谢谢

使用UIBarButtonItem的customView,将UILAbel设置为customView。该项目将不可单击

UILabel *yourLabel = ...;
UIBarButtonItem *theBarItem = [[UIBarButtonItem alloc] initWithCustomView:yourLabel];

仅此而已。

听起来像是在使用UIBarButtonItem,而实际上应该使用UILabel。为什么?