How do I make a table view cell dynamic in size?
I am using the
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 100;
}
to make all the 开发者_如何学编程cells big enough for the biggest cell however I would like to make the cell big enough for its perspective contents. Any help is appreciated.
You can't change the width of individual cells, that is part of the UITableView. You can return a different value for the tableView:heightForRowAtIndexPath:
for each row, that is how you make rows different heights. For example:
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
MyThing *theThing = [arrayOfData objectAtIndex:indexPath.row];
return theThing.linesOfData * 17; //made up number for font height
}
精彩评论