File tree Expand file tree Collapse file tree
TableViewCellWithAutoLayout/TableViewController Expand file tree Collapse file tree Original file line number Diff line number Diff 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.
You can’t perform that action at this time.
0 commit comments