Objective C - Problems with texts in cell

0

I'm trying to create cells with dynamic height, with only one label I have no problem, however, when I put two or more labels inside my cell, I cut part of the labels or in some cases it does not show it.

The height is like this:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

// Calculo
if(!self.myCell) {
    self.myCell = [self.tabla dequeueReusableCellWithIdentifier:@"DynamicTableViewCell"];
}

// Config
self.myCell.label.text = [_dataSource[indexPath.row] uppercaseString];
self.myCell.label2.text = [_dataSource[indexPath.row] uppercaseString];

// Layout
[self.myCell layoutIfNeeded];
[self.myCell setNeedsLayout];

// Altura
CGFloat height = [self.myCell.contentView systemLayoutSizeFittingSize:UILayoutFittingExpandedSize].height;

return height;
}

Additionally, my labels have constrains in the Superview and a space between them. In addition, the number of lines is 0 and its mode of break (Line Break) is Word Wrap

    
asked by JonhHdz 19.07.2017 в 19:19
source

1 answer

0

The same is complicating you a lot. If you have correctly put the constraints and are able to draw the cell you just have to return UITableViewAutomaticDimension and implement a more method

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return  UITableViewAutomaticDimension;
}
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return  UITableViewAutomaticDimension;
}
    
answered by 19.07.2017 / 20:47
source