繁体   English   中英

表格视图,静态单元格,更改单元格高度

[英]Table View, Static Cells, changing Cell Height

我了解使用动态TableView,可以使用以下方法设置像元高度:tableView:heightForRowAtIndexPath:

但是,如果我使用“静态表视图”(而不是“动态”)“带节”,我想以编程方式将单元格的高度设置为0。

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

//used to set the height of a cell

CGFloat result;
switch(indexPath.section) {

    case 0:
    {
        //How do I get the ROW number in this section?
        result = 44;
        break;
    }

    case 1:
    {
        //this works if I want to set all of the rowels to this height.
        result = 250;
        break;
    }

}

问题以另一种方式提出,如果我有indexPath.section ...我该怎么做... indexPath.Section.row?

您可以直接使用indexpath.row 无需编写indexPath.Section.row

在iOS中, NSIndexPath获得额外的职责 苹果有两个不同的文档,这有点令人困惑。

如其他答案所述,您将获得:

获取部分索引

  • 部分属性

获取行或项目的索引

  • 属性
  • 项目属性

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM