大家好,
我在Interface Builder中设计了一个视图,并与其控制器正确连接。 其中有一些UILabel会充满大量的文字。 但是,即使我在IB中声明了“自动换行”并将行设置为0,我也只能显示第一行。 我注意到,如果我在IB中增加UILabel的高度,所有文本都会在多行中正确显示,但我不能这样做,因为文本可能会有所不同。
UILabel不应该调整自己的大小以适应所有文本吗? 另外,如果我以编程方式构建UILabel,我可以成功完成自动换行,为什么不能对IB做同样的事情呢?
我究竟做错了什么 ?
谢谢莱昂纳多
HI all,
I have designed a view in Interface Builder and connected correctly with its controller. There some UILabel in it that are going to be filled with lot of text. But, even if I have declared "word wrap" and set line to 0 in IB, I can display only first line. I notice that if I increase the height of the UILabel in IB, all the text display properly in multi line, but I cannot do that because text may vary.
Shouldn't the UILabel resize itself to fit all the text ? Also, if I built the UILabel programmatically I can succesfully accomplish a word wrap, why cannot do the same with IB ?
What am I doing wrong ?
thanks Leonardo
最满意答案
我找到的唯一解决方案是在UILabel上以编程方式调用sizeToFit。 我想知道IB中是否有一个设置来模拟这个命令。
The only solution I found is to call sizeToFit programmatically on UILabel. I wonder if there's a setting in IB to emulate this command.
IBOutlet UILabel不会调整大小(IBOutlet UILabel do not get resized)大家好,
我在Interface Builder中设计了一个视图,并与其控制器正确连接。 其中有一些UILabel会充满大量的文字。 但是,即使我在IB中声明了“自动换行”并将行设置为0,我也只能显示第一行。 我注意到,如果我在IB中增加UILabel的高度,所有文本都会在多行中正确显示,但我不能这样做,因为文本可能会有所不同。
UILabel不应该调整自己的大小以适应所有文本吗? 另外,如果我以编程方式构建UILabel,我可以成功完成自动换行,为什么不能对IB做同样的事情呢?
我究竟做错了什么 ?
谢谢莱昂纳多
HI all,
I have designed a view in Interface Builder and connected correctly with its controller. There some UILabel in it that are going to be filled with lot of text. But, even if I have declared "word wrap" and set line to 0 in IB, I can display only first line. I notice that if I increase the height of the UILabel in IB, all the text display properly in multi line, but I cannot do that because text may vary.
Shouldn't the UILabel resize itself to fit all the text ? Also, if I built the UILabel programmatically I can succesfully accomplish a word wrap, why cannot do the same with IB ?
What am I doing wrong ?
thanks Leonardo
最满意答案
我找到的唯一解决方案是在UILabel上以编程方式调用sizeToFit。 我想知道IB中是否有一个设置来模拟这个命令。
The only solution I found is to call sizeToFit programmatically on UILabel. I wonder if there's a setting in IB to emulate this command.
发布评论