I had the same problem. If your restrictions are set correctly, you need to set preferredMaxLayoutWidth
for each UILabel
that you have in the cell, just before the cell returns. Here is a sample code
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
cell.lblTitle.text = @"N";
cell.lblDetails.text = @"bla bla";
cell.lblOther.text = @"other text";
CGfloat leftPading =
CGfloat rightPading =
cell.lblTitle.preferredMaxLayoutWidth = CGRectGetWidth(tableView.bounds)-(leftPading +rightPading);
cell.lblDetails.preferredMaxLayoutWidth = CGRectGetWidth(tableView.bounds)-(leftPading +rightPading);
[cell setNeedsUpdateConstraints];
[cell updateConstraintsIfNeeded];
return cell;
}
, ,
, .