简体   繁体   中英

Table View, Static Cells, changing Cell Height

I understand that using a dynamic TableView, you can set the Cell Height using... 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.

-(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?

You can use indexpath.row directly. No need to write indexPath.Section.row .

In iOS, the NSIndexPath gets extra duties . 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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