2010-05-24 125 views
0

我想使用自定义单元格,我的自定义单元格的大小为320 * 220像素。 我的桌子尺寸是320 * 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; 

}

回答

2

单元格被调整到行高。尝试设置tableView.rowHeight = 220

编辑:避免执行tableView:heightForRowAtIndexPath:;如果你这样做,它被称为为每行,这将成为一个问题,当您的表变大(更多请参阅docs

+0

Thanx Tc它的工作 – Rahul 2010-05-24 20:14:59

+0

哇,不知道,谢谢! – 2010-05-24 20:24:07

0

不是真的知道我跟着你,但如果它的任何帮助重叠通常是因为你没有设置一个实现代码如下的rowHeight的。试试这个 -

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

Thanx Tejaswi。有效!!! :) – Rahul 2010-05-24 20:15:33