I am having an app in which I have a Tableview and on that tableview\'s each row I am dynamically creating a custom tableview cell.
Below is the cod
Try this
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return [self.tableName.dataSource tableView:self.tableName cellForRowAtIndexPath:indexPath].contentView.frame.size.height;
}
And in your cellForRowAtIndexPath delegate if you are using label then first set number of lines to label as 0, then set label text and then add sizeTofit property of it. Like this
[cell.yourLabelName setNumberOfLines:0];
cell.yourLabelName.text = @"Your long or short text";
[cell.yourLabelName sizeToFit];
This will expand your label height as per the text in it.
After that you can set the size of your cell contentView like this.
cell.contentView.frame = CGRectMake(cell.contentView.frame.origin.x, cell.contentView.frame.origin.y, cell.contentView.frame.size.width,"Height of label" + cell.contentView.frame.size.height);