-1
可能重复:
Setting custom UITableViewCells heightUITablecell HIGHT的动态大小
我有其中包含的tableview定制cells.I有一个包含上表cells.But要显示的文本对象文本的大小可能会有所不同,因此,根据内容尺寸电池的尺寸应该增加还是decreased.How做到这一点?
可能重复:
Setting custom UITableViewCells heightUITablecell HIGHT的动态大小
我有其中包含的tableview定制cells.I有一个包含上表cells.But要显示的文本对象文本的大小可能会有所不同,因此,根据内容尺寸电池的尺寸应该增加还是decreased.How做到这一点?
首先计算根据您的text
的cell
需要sizeHeight。
CGSize boundingSize = CGSizeMake(220.0, 500);
//Adjust your Font name and size according to you
CGSize requiredSize = [cell.txtViewDescription.text sizeWithFont:[UIFont fontWithName:@"Helvetica" size:13.0] constrainedToSize:boundingSize lineBreakMode:UILineBreakModeWordWrap];
CGFloat requiredHeight = requiredSize.height;
requiredHeight = requiredHeight + 20.0;
现在用这个方法来分配cell Height
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
这只是一个想法。现在所有的东西都依赖于你的逻辑。祝你好运!
很多环节都在那里。像[此](http://www.cimgf.com/2009/09/23/uitableviewcell-dynamic-height/)例如。顺便说一句,你需要接受更多的答案。您率为0% – FluffulousChimp
太多的讨论已可用于这个问题 – cancerian