Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/106.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_Truncate - Fatal编程技术网

Ios 如何阻止UIBarButtonItem文本截断?

Ios 如何阻止UIBarButtonItem文本截断?,ios,objective-c,uibarbuttonitem,truncate,Ios,Objective C,Uibarbuttonitem,Truncate,我在导航栏中有一个标题为“保存”的UIBarButtonItem。当我转换到全屏UIPopoverController并将其关闭时,我的UIBarButtonim中的文本将被截断为“S..e”。对于所有其他片段和视图,我返回时没有问题 我已经尝试手动更改宽度并设置“可能字数”以包含长单词,但我无法停止截断 如果有区别的话,我正在使用自定义字体。尝试使用自定义视图初始化UIBarButtonim [[UIBarButtonItem alloc] initWithCustomView:yourVie

我在导航栏中有一个标题为“保存”的
UIBarButtonItem
。当我转换到全屏
UIPopoverController
并将其关闭时,我的UIBarButtonim中的文本将被截断为“S..e”。对于所有其他片段和视图,我返回时没有问题

我已经尝试手动更改宽度并设置“可能字数”以包含长单词,但我无法停止截断


如果有区别的话,我正在使用自定义字体。

尝试使用自定义视图初始化UIBarButtonim

[[UIBarButtonItem alloc] initWithCustomView:yourView];

只需确保您的自定义视图具有正确的框架(例如,对于UILabel,宽度足以不截断其内容)。事情应该会很顺利。

也许会有帮助,但是一个带有自定义视图(例如:
UILabel
)的
UIBarButtonItem
,插入到
UIToolbar
中,只要
translatesAutoResizingMackintoConstraints
设置为
false
,它就可以具有其内容的固有大小。我相信这也适用于
UINavigationBar

private let barButtonLabel: UIBarButtonItem = {
    let label = UILabel(frame: .zero)
    label.translatesAutoresizingMaskIntoConstraints = false
    return UIBarButtonItem(customView: label)
}()

这似乎是唯一正确的方法。我也能够通过在单词末尾添加空格“”来实现此结果。令人沮丧的是,您需要借助一些小技巧或过多的代码来修复甚至不应该存在的问题。谢谢你的帮助!