【问题标题】:Custom Cell over lapping自定义单元格重叠
【发布时间】:2011-02-23 09:41:06
【问题描述】:

我正在尝试使用自定义单元格, 我的自定义单元格大小为 320*220 像素。 我的桌子大小是 320* x 1500,足够大 我已将自定义单元格的视图按比例设置为填充模式。 但是当我使用自定义单元格填充表格时,我看到的只是第一行。我总共有四行要以自定义方式填写。但是它们重叠了,我看不到任何桌子.. 他们确实看起来,但重叠,任何提示..关于它为什么会发生 我需要对笔尖进行更改吗?

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 静态 NSString *CellIdentifier = @"CustomCell";

CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil)  
{
    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
    for (id oneObject in nib)
        if ([oneObject isKindOfClass:[CustomCell class]])
            cell = (CustomCell *)oneObject;
}






cell.iconImage.image = [UIImage imageNamed:[NSString stringWithFormat:@"beach%d.jpg",indexPath.row+1]];
cell.title.text=[[RArrray objectAtIndex:indexPath.row] objectForKey:@"Beach"];

return cell;

}

【问题讨论】:

    标签: iphone iphone-sdk-3.0


    【解决方案1】:

    单元格的大小调整为行高。尝试设置tableView.rowHeight = 220

    编辑:避免实现tableView:heightForRowAtIndexPath:;如果你这样做,它会为每一行调用,当你的表变大时,这会成为一个问题(更多信息请参见docs

    【讨论】:

      【解决方案2】:

      不太确定我是否关注你,但如果有帮助,通常会发生重叠,因为你没有为 tableview 设置 rowHeight。试试这个 -

      - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
          return 220; // Or whatever your cell height is?
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-05-08
        • 2017-02-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多