Skip to content

Commit 43db8a5

Browse files
committed
Replace layoutSubviews with layoutIfNeeded
1 parent c682c9d commit 43db8a5

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

TableViewCellWithAutoLayout/TableViewController/RJTableViewCell.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ - (void)layoutSubviews
9797
{
9898
[super layoutSubviews];
9999

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

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

0 commit comments

Comments
 (0)