在使用UITableView的时候,UITableViewCell的高度可能要改变。改变行高有两种情况,第一种是改变所有的行高。第二种是改变特定行的行高。

第一种,改变所有行的行高。就是类似下面的效果。

iPhone开发笔记 (4) 如何改变UITableViewCell的行高

这里要使用UITableViewDelegate的方法:

//设置rowHeight - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 91.5; }第二种,如果要指定改变某个行的行高。就类似下面的效果。

iPhone开发笔记 (4) 如何改变UITableViewCell的行高


只要对上面的方法做一下修改如下:

//设置rowHeight - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.section == 0 && indexPath.row == 0) { return 220; } else { return 40; } }


相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-06
  • 2021-09-22
  • 2021-04-30
  • 2022-01-12
  • 2022-12-23
  • 2021-11-22
猜你喜欢
  • 2021-05-31
  • 2021-11-26
  • 2022-12-23
  • 2021-06-15
相关资源
相似解决方案