-3

I have a simple question, not able to sort it out. I have a UITableView in my application. There are 3 section and each section has 3 rows.

I want to increase the height of first cell of the first section. I am using the delegate for this but it increases the height of the first cell of the third section.

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
{    
    if (indexPath.row == 0 && sectionValue==0) 
    {         
        sectionValue=1;
        return 180.0;        
    }
    else
    {
        return 44.0;        
    }   
}
Matt
  • 72,564
  • 26
  • 147
  • 178
Alok Chandra
  • 1,867
  • 1
  • 20
  • 45
  • sectionValue is set 0 in viewdidload. – Alok Chandra Jul 03 '12 at 11:40
  • 1
    You must check `indexPath.section == 0` too! (+ votedown because this question asked more than ten times!) – Hamed Rajabi Jul 03 '12 at 11:42
  • possible duplicate of [iPhone + UITableView + row height](http://stackoverflow.com/questions/1635783/iphone-uitableview-row-height) – Monolo Jul 14 '12 at 11:47
  • possible duplicate of [Different height for alternative cell in UITableView](http://stackoverflow.com/q/3529246/), [Manage height of UITableView cell](http://stackoverflow.com/questions/8122814/manage-height-of-uitableview-cell) – outis Jul 14 '12 at 20:20

2 Answers2

2

You can directly use indexPath.section -

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

    if (indexPath.row == 0 && indexPath.section==0) 
    {  
        return 180.0;

    }
    else
    {
        return 44.0;

    }
}
rishi
  • 11,622
  • 4
  • 39
  • 58
0

try this......

 indexPath.section
Rinju Jain
  • 1,698
  • 1
  • 14
  • 23