首页 文章

UITableView单元格的高度

提问于
浏览
-3

我有一个简单的问题,无法解决它 . 我的申请表中有 UITableView . 有3个部分,每个部分有3行 .

我想增加第一部分的第一个单元格的高度 . 我正在使用委托,但它增加了第三部分的第一个单元格的高度 .

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
{    
    if (indexPath.row == 0 && sectionValue==0) 
    {         
        sectionValue=1;
        return 180.0;        
    }
    else
    {
        return 44.0;        
    }   
}

2 回答

  • 0

    你可以直接使用 indexPath.section -

    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
    {
    
        if (indexPath.row == 0 && indexPath.section==0) 
        {  
            return 180.0;
    
        }
        else
        {
            return 44.0;
    
        }
    }
    
  • 2

    试试这个......

    indexPath.section
    

相关问题