简体   繁体   English

如何在分组样式表中设置单元格的高度?

[英]How to set height of cell in grouped style table?

I have made a table with two types of custom cells using interface builder: 我已经使用界面生成器制作了具有两种类型的自定义单元格的表格:

在此处输入图片说明

Everything works fine, except lower cell's height is same as cell above it. 一切正常,除了下部单元格的高度与其上方单元格的高度相同。 It has everything i put - UIImageView etc... 它具有我放的所有内容-UIImageView等...

So I was thinking if it is not possible to change cell height when table style is grouped? 因此,我在考虑将表格样式分组时是否无法更改单元格高度?

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath  *)indexPath{

   if (indexPath.row == 1) {

   return 100;
   }

   return 44;
}

We can use UITableview Delegate Methods : 我们可以使用UITableview的Delegate方法:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
   if (indexPath.row == 1)
      {
          return 60;
      }
   else
      {
          return 44;
      }
 }    

You have to use this 你必须用这个

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

{ return 75.0f; {返回75.0f;

} }

it is use full for me. 对我来说用光了。

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

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