-1

Possible Duplicate:
Setting custom UITableViewCells height

I have a tableview which contains custom cells.I have an object which contains text to be displayed on table cells.But the size of text may vary,So depending on the content size the size of cell should be increased or decreased.How to do this?

Community
  • 1
  • 1
priyanka vijesh
  • 227
  • 1
  • 3
  • 7
  • Many links are out there. Like [this](http://www.cimgf.com/2009/09/23/uitableviewcell-dynamic-height/) for example. By the way, you need to accept more answers. Your rate is 0% – FluffulousChimp Sep 20 '12 at 05:06
  • too many discussions already available for this question – cancerian Sep 20 '12 at 05:33

1 Answers1

1

First Calculate the cell required sizeHeight according to your text.

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;

Now use this method to assign cell Height

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

This is just an Idea. All things depend on your logics now. Good Luck!

TheTiger
  • 13,264
  • 3
  • 57
  • 82