【发布时间】:2024-05-19 20:05:02
【问题描述】:
这是我的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 行,然后再重复第 4 次直到 10 行???
+-----------------------+
| A
+-----------------------+
| B
+-----------------------+
| C
+-----------------------+
| D
+-----------------------+
| A (repeated)
+-----------------------+
| B (repeated)
+-----------------------+
| C (repeated)
+-----------------------+
| D (repeated)
+-----------------------+
| A (repeated)
+-----------------------+
| B (repeated)
+-----------------------+
啊,[titleArray count] 等于 10。
kCustomCellID 是正确的。
谢谢。
一个
【问题讨论】:
-
我建议逐步使用调试器并一次检查一个值。如果需要,您可以使用“po object”打印出对象的原始详细信息。
标签: iphone objective-c ipad uitableview