UILabel doesn't show text properly in Emulator and real device as it does in Interface Builder

房东的猫 提交于 2019-12-08 06:50:52

问题


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

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

But when I run and test them on emulator and device they become truncate even though they look fit in the 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.

Emulator

Interface Builder

Any help to overcome this?

Thanks


回答1:


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

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];

Hope that works !




回答2:


As there's a change in DateFormatter it's creating a problem. In your XIB, date is in different format than your device.

You can set Minimum Font Size for your label from your XIB. Check below screenshot.

I hope it'll solve your problem.

Thanks,

Hemang.



来源:https://stackoverflow.com/questions/16828737/uilabel-doesnt-show-text-properly-in-emulator-and-real-device-as-it-does-in-int

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!