RuslTG
RuslTG

Reputation: 51

AutoLayout + UITableViewCell + Height (not worked)

I am trying to autoresize table cell with autolayout. But it seems TableView ignores height constraints.

I know that "tableView: heightForRowAtIndexPath:" can do this.

But how to avoid to use height hardcoding ? Is any other ways ?

screen shot 1:

https://dl.dropbox.com/s/3spak2koe2s6jif/1.png

screen shot 2:

[https://dl.dropbox.com/s/dnumxqv28bjh939/2.png]2

Upvotes: 1

Views: 1494

Answers (1)

nerowolfe
nerowolfe

Reputation: 4817

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static UITableViewCell *cell;
    if (cell == nil) {
        cell = [tableView dequeueReusableCellWithIdentifier: @"YourCell"];
    }
    [self configureCell:cell forIndexPath:indexPath]; // making text assignment and so on
    return [cell.contentView systemLayoutSizeFittingSize: UILayoutFittingCompressedSize].height + 1.0f;
}

Upvotes: 2

Related Questions