开发者

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
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜