mardi 4 août 2015

UILabel in UITableViewCell using Autolayout sizes correctly but only wraps on rotation

I use the programatic constraints from the WWDC '14 talk on UITableViews so that my app can support dynamic text and adjust the height of my table view cells automatically. But the wrapping only shows up if I rotate the device to landscape and back. The first picture below shows this: the initial view is wrong. The second shows what I expected, but I only get the correct behaviour after I rotate to landscape and back.

Notice that the size of the cells is correct: the auto layout system has figured out that I need two lines of space, and yet the text did not wrap.

I tried setting the line break mode - it sort of works (breaks at a character or word depending on the mode, but I don't see the rest of the string until I rotate).

The constraints for the label are identical to the ones in the WWDC '14 talk. I get not auto layout complaints. I have set number of rows of the UILabel to 0, set the row height to UITableViewAutomaticDimension and set the estimated row height.

Has anyone seen this before and fixed it? What have I done wrong?

enter image description here

Second picture: enter image description here



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire