這是我的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