Define height of one specific table cell

前端 未结 2 474
情深已故
情深已故 2021-01-25 06:30

I have a tableView with two custom cells. I need to to define the height of one cell but leave the other alone. I am trying to learn Objective-C, so any help would be greatly ap

相关标签:
2条回答
  • 2021-01-25 06:55

    To specify the height of a table cell, you need to provide the UITableViewDelegate method tableView:heightForRowAtIndexPath:.

    I am trying to learn Objective-C, so any help would be greatly appreciated!

    Your first port of call should be the documentation.

    0 讨论(0)
  • 2021-01-25 06:57

    In your UITableView delegate, implement the routine tableView:heightForRowAtIndexPath: and return whatever height you want for whatever row. Something like:

    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
    {
      if ( indexPath.row == 0 )   // 1st row
         return 25.0;
      else
         return 35.0;
    }
    
    0 讨论(0)
提交回复
热议问题