StackUnderflow
StackUnderflow

Reputation: 2463

Auto Layout, custom UITableViewCell, growing labels

I'm trying to solve this Auto Layout puzzle with a custom UITableViewCell which contains two labels that may grow vertically depending on their content i.e. number of lines. I've almost got it right, except that one label in one cell does not grow as expected! Please see screenshot where highlighted in red dashed line – the label does not end with a bracket, its text is clipped instead.

enter image description hereenter image description here Please find the simple Xcode project here.

Upvotes: 1

Views: 375

Answers (1)

StackUnderflow
StackUnderflow

Reputation: 2463

In my case there are two multiline labels and not just one as in other posts, and so there are 2 elements that effect the height of a cell. But regardlesss of that the soluion is to force the cell to do its layout. So after calling dequeueReusableCellWithIdentifier() to get the cell, just add:

// fix for iOS lauout bug
cell.setNeedsLayout()
cell.layoutIfNeeded()

All starting and ending brackets are visible i.e. to text clipping :-) enter image description here

Upvotes: 3

Related Questions