UILabel 无法像在 Interface Builder 中那样在模拟器和真实设备中正确显示文本 [英] UILabel doesn't show text properly in Emulator and real device as it does in Interface Builder

查看:23
本文介绍了UILabel 无法像在 Interface Builder 中那样在模拟器和真实设备中正确显示文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些静态标签和静态文本,不会永远改变.

I have some static Label with static text that will not change forever.

我在 Interface Builder 中调整布局,直到它们看起来很棒.并使用 Cmd + = 让所有标签的大小适合其内容.

I adjust the layout in Interface Builder until they look great. and use Cmd + = to let all label's size fit their contents.

但是当我在模拟器和设备上运行和测试它们时,即使它们看起来适合 Interface Builder,它们也会被截断.

But when I run and test them on emulator and device they become truncate even though they look fit in the Interface Builder.

我已在 iOS 5.0、6.1 和 3.5、4 英寸(包括 iphone5 设备)上对其进行了测试.所有结果都与 Interface Builder 中的不同.

I have test it on iOS 5.0, 6.1 and on 3.5, 4 inches include on iphone5 device. All the result are different from in Interface Builder.

模拟器

界面生成器

有什么帮助来克服这个问题吗?

Any help to overcome this?

谢谢

推荐答案

您可以尝试使用此代码来拟合标签内容.

You can try using this code for fitting the label content.

为此,您需要为标签设置一个 IBOutlet,然后,

For that you need to have a IBOutlet for the label and then after that,

在加载视图时使用此代码:

use this code when you load the view :

[self.label sizeToFit];

希望有效!

这篇关于UILabel 无法像在 Interface Builder 中那样在模拟器和真实设备中正确显示文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆