-8

I am working on UITableView and the cells have different contents like a Facebook cell, so how can i change the height of each cell accordingly?

rohith r
  • 3
  • 1

2 Answers2

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

UIFont *font = [UIFont systemFontOfSize:20];
NSDictionary *userAttributes = @{NSFontAttributeName: font,
                             NSForegroundColorAttributeName:         [UIColor blackColor]};
NSString *text = @"Your label text";

CGSize textSize = [text sizeWithAttributes: userAttributes];

ht = 20;

if (textSize.width > [FunctionUtils getViewWidth]) {

ht = (textSize.width/([FunctionUtils getViewWidth]));
ht = (ceil(ht))*20+35;
//20 font size
}

return ht;
}
yoshiiiiiiii
  • 953
  • 8
  • 20
0

You Should follow the link http://www.raywenderlich.com/73602/dynamic-table-view-cell-height-auto-layout This is best way to achieve to do this

Nirmal Choudhari
  • 559
  • 5
  • 17