Skip to content

Commit

Permalink
Replace layoutSubviews with layoutIfNeeded
Browse files Browse the repository at this point in the history
  • Loading branch information
smileyborg committed Jan 16, 2014
1 parent c682c9d commit 43db8a5
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ - (void)layoutSubviews
{
[super layoutSubviews];

// The below call to layoutSubviews on the table view cell's contentView should NOT be necessary.
// However, in some (but not all!) cases it appears as though the super implementation does not call
// layoutSubviews on the contentView, which causes all the UILabels to have a frame of CGRectZero.
[self.contentView layoutSubviews];
// Make sure the contentView does a layout pass here so that its subviews have their frames set, which we
// need to use to set the preferredMaxLayoutWidth below.
[self.contentView setNeedsLayout];
[self.contentView layoutIfNeeded];

// Set the preferredMaxLayoutWidth of the mutli-line bodyLabel based on the evaluated width of the label's frame,
// as this will allow the text to wrap correctly, and as a result allow the label to take on the correct height.
Expand Down

0 comments on commit 43db8a5

Please sign in to comment.