Sometimes when we use Tableviewcell to present our data, we receive more data than we set when we initialize it, and we need to adapt the cell height. Here's the code to return the cell height.
-(CGFloat) TableView: (UITableView *) TableView Heightforrowatindexpath: (Nsindexpath *) Indexpath
{
Lucknumberlabel = [[Uilabel alloc] Initwithframe:cgrectmake (+, kScreenWidth-90, 40)];
NSString *str = [[Dataarray[indexpath.row] objectforkey:@ "numbers"] componentsjoinedbystring:@ ","];
Lucknumberlabel.text = [NSString stringwithformat:@ "Your Lucky number:%@", str];
Lucknumberlabel.font = font (13.0);
Lucknumberlabel.linebreakmode = nslinebreakbycharwrapping;
Lucknumberlabel.numberoflines = 0;
Self-adaptive height
CGRect txtframe = lucknumberlabel.frame;
Lucknumberlabel.frame = CGRectMake, kScreenWidth-90, txtFrame.size.height = [Lucknumberlabel.text Boundingrectwithsize:cgsizemake (TxtFrame.size.width, Cgfloat_max) options:nsstringdrawinguseslinefragmentorigin | Nsstringdrawingusesfontleading Attributes:[nsdictionary DictionaryWithObjectsAndKeys:luckNumberLabel.font, Nsfontattributename, nil] context:nil].size.height);
Lucknumberlabel.frame = CGRectMake (n, kScreenWidth-90, txtFrame.size.height);
return Lucknumberlabel.maxy + 50;
}