2

I’m using Swift 4, Xcode 9

I have a custom table cell with a label in it. It is set to have number of lines = 0 (unlimited) and text wrap. See the following cell: enter image description here

I have the leading layout set to be as big as the image shows, but trailing is set to be flush with the right side of the cell. When I set a background on the label, it starts at the beginning of the text and spans all the way to the right of the cell, as expected. Therefore, it looks like the word “septum” should certainly fit on the first line.

Question: what are the possibilities for why it’s wrapping incorrectly?

I have not found any similar question/situation. Thanks for any suggestions!

Coltuxumab
  • 615
  • 5
  • 16
  • Please show your constraint/layout setup. If the constrains are correct, my guess is that there is either a non-breaking space between the two underlined words, or an accidental newline after "or". – Tamás Sengel Apr 17 '18 at 21:41

1 Answers1

5

When updating our Application for iOS 11 we had similar Problems like the one you are presenting here. Here a example:

enter image description here (please apologize for the bad quality i only have this screenshot from that iteration of the application.)

As you can see, the word "Videos" could fit perfectly in the space between the word "und" in the upper row and the trailing end of the Label. But it was always forced into another line.

In my research about this problem I came along with this post. The answer in this post shows, the difference between iOS 10 and iOS 11. It seems, that apple implemented a workaround for "orphaned texts" in its basic UI-classes which display texts. More about "orphaned texts" in this article also mentioned in the linked answer.

Probably the intention from Apple here was, that all texts will look nicer because as mentioned in the article, orphaned texts produce a high visual rustle and we will interpret a paragraph as displeasingly.

So in my case, I just changed the text which will be shown by the label, to something, that looks better than this chaos in the screenshot above.

Another Solution would be, to adjust your constraints of the View so that the text will fit in one line.

AFAIK there is no option, that could be set, to remove this behavior from the UILabel or similar UIKit classes.

Marcel T
  • 659
  • 1
  • 7
  • 28