I have a UITableView that has five static cells. I need the cell height of one cell to adjust automatically to its contents, which is one UILabel.
Is there any way I
I was looking for an answer to this as well and found this solution, which i tested and works perfectly in iOS8.
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row == 2) //Dynamic Height
{
return UITableViewAutomaticDimension;
}
else
{
return 50; // Static Height
}
}
For iOS 8, I found out that you cannot do the same strategy as for Dynamic Table View Cell.
To automatically adjust the height of static cells, I implement these two UITableViewDelegate methods:
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewAutomaticDimension;
}
-(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 44;
}
Hope it helps.