这是我的cellForRowAtIndexPath
。表格视图中的重复单元格
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Maledetta"];
if (cell == nil) {
UIViewController *c;
if (!IS_IPAD) c = [[UIViewController alloc] initWithNibName:@"NewsRow" bundle:nil];
else c = [[UIViewController alloc] initWithNibName:@"NewsRow_ipad" bundle:nil];
cell = (NewsRowController*)c.view;
if ([titleArray count] > 0) {
[(NewsRowController*)cell setCellDataWithName:[titleArray objectAtIndex:indexPath.row]
andDate:[descArray objectAtIndex:indexPath.row]
day:[dayArray objectAtIndex:indexPath.row]
month:[monthArray objectAtIndex:indexPath.row]];
}
[c release];
}
return cell;
}
为什么它显示我只有4行,之后,重复第一次,其他时间第四次,直到十?
+-----------------------+
| A
+-----------------------+
| B
+-----------------------+
| C
+-----------------------+
| D
+-----------------------+
| A (repeated)
+-----------------------+
| B (repeated)
+-----------------------+
| C (repeated)
+-----------------------+
| D (repeated)
+-----------------------+
| A (repeated)
+-----------------------+
| B (repeated)
+-----------------------+
啊,[titleArray count]
等于10
。 kCustomCellID
是正确的。
谢谢。
A
我会建议逐步使用调试器并逐个检查您的值。如果需要,可以使用“po对象”打印出对象的原始细节。 – clifgriffin 2011-02-16 20:18:16