简体   繁体   English

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

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

I understand that using a dynamic TableView, you can set the Cell Height using... tableView:heightForRowAtIndexPath: 我了解使用动态TableView,可以使用以下方法设置像元高度:tableView:heightForRowAtIndexPath:

However, if I am using A Static Table View ( not Dynamic), With Sections, I would like to programmatically set the height of a cell to 0. 但是,如果我使用“静态表视图”(而不是“动态”)“带节”,我想以编程方式将单元格的高度设置为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;
    }

} }

The question asked another way, If I have the indexPath.section... how can I do something like... indexPath.Section.row? 问题以另一种方式提出,如果我有indexPath.section ...我该怎么做... indexPath.Section.row?

You can use indexpath.row directly. 您可以直接使用indexpath.row No need to write indexPath.Section.row . 无需编写indexPath.Section.row

In iOS, the NSIndexPath gets extra duties . 在iOS中, NSIndexPath获得额外的职责 It is a bit confusing as Apple has two different pieces of documentation. 苹果有两个不同的文档,这有点令人困惑。

As noted in the other answers, you get: 如其他答案所述,您将获得:

Getting the Section Index 获取部分索引

  • section property 部分属性

Getting the Index of a Row or Item 获取行或项目的索引

  • row property 属性
  • item property 项目属性

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

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