0

Sorry i know this question has been asked before but i can't seem to get it to work, i would like to change the height of the first cell in my UITableView and keep the rest as default 44. I have implemented the below code (tried various others) and my application builds but the cell height does not change. Any help on this would be great.

 -(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {

    if (indexPath.row == 0) {
        return 150;
    }
    else {
        return 44;
    }
}
Ajith Renjala
  • 4,934
  • 5
  • 34
  • 42
burrGGG
  • 617
  • 2
  • 9
  • 18
  • 1
    try - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath – Nikita Shytyk Aug 28 '14 at 08:25
  • 1
    possible duplicate of [Change Height of a UITableViewCell](http://stackoverflow.com/questions/8543846/change-height-of-a-uitableviewcell) – Yucel Bayram Aug 28 '14 at 08:29

2 Answers2

1
estimatedHeightForRowAtIndexPath

is used to calculate the position / size of the scroll bar on the side when using autoLayout, not the cell height. You need:

heightForRowAtIndexPath
Simon McLoughlin
  • 8,293
  • 5
  • 32
  • 56
1

How did this code work out for you?

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
     if (indexPath.row == 0) 
          return 150;
      else
          return 44;
}
Ajith Renjala
  • 4,934
  • 5
  • 34
  • 42
  • it didn't do anything to the cell.. I'm not sure if in storyboard maybe there is a setting that fixes the height? – burrGGG Aug 28 '14 at 08:37
  • Sorted, i didn't need 'estimated' in front of height. – burrGGG Aug 28 '14 at 08:39
  • @burrGGG i've explained the difference between the 2 in my answer – Simon McLoughlin Aug 28 '14 at 08:50
  • @burrGGG Adding the documentation comments for 'estimated' thing, // Use the estimatedHeight methods to quickly calcuate guessed values which will allow for fast load times of the table. // If these methods are implemented, the above -tableView:heightForXXX calls will be deferred until views are ready to be displayed, so more expensive logic can be placed there. – Ajith Renjala Aug 28 '14 at 08:54