更改UITableViewCell的高度

use*_*985 15 objective-c uitableview ios

我想做一个UITableViewCell更大的.我怎么能这样做,我试过调整它的框架,但没有任何反应.我能做什么?

Sha*_*ell 34

你需要实现

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
Run Code Online (Sandbox Code Playgroud)

UITableViewDelegate中的方法.


Use*_*892 17

你可以这样做..

//Change the Height of the Cell [Default is 44]:
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath*)indexPath
{
  if (indexPath.section == 0) {
   if (indexPath.row == 1) {
     return 90;
   }
  }
  return 44;
}
Run Code Online (Sandbox Code Playgroud)

我希望这能帮到您..


sca*_*guy 6

有两个步骤可以更改表格单元格的高度,而无需任何其他代码:

  1. Table View从故事板中选择您的.在Size Inspector改变Row Height.
  2. 选择您的Table View Cell,并在Size Inspector更改时选择它Row Height.

请注意,您必须设置BOTH表视图的的Row Height属性和表格视图单元格的Row Height属性.

如果您只设置其中一个,它将无法正常工作.