UILabel line break is ignored when building

I am trying to configure a three-line UILabel using Xcode 4.2 and Interface Builder, creating for iOS 5. After placing the UILabel, I set the number of lines to 3 (this problem also occurs with the number of lines set to 0), and I used the -Return option to split correctly strings in the text property. All this is displayed correctly in the preview of the storyboard in Interface Builder. The problem is that when I create and run the application in the simulator, line breaks are completely ignored, and the text simply wraps around the UILabel view wherever it needs, as if there were no line breaks in the text.

The obvious quick fix is ​​to simply set the text for UILabel in your code or make three UILabels. No problems. I am simply annoyed why this happens when the shortcut is configured exclusively in IB. Does anyone face the same problem?

+6
source share
2 answers

This should probably open as an error, but here is a workaround:

Instead of the Return option, use control-Return and press it twice (leaving a blank line between the lines of text in the storyboard). Then it will be correctly displayed both in the storyboard and on the device.

+9
source

Using this label property,

label.lineBreakMode=UILineBreakModeCharacterWrap; label.numberOfLines=0; 

We can give a complete paragraph to one example shortcut shown in the screenshot.

enter image description here

+2
source

Source: https://habr.com/ru/post/903125/


All Articles