我正在使用字典數組填充表視圖。數組和字典的內容被解析沒有問題。但是,該表中填充了[數組數量]的單元格,其內容索引爲0。在我看來,indexPath.row爲所有單元格返回0。我如何使用相應的索引填充每個單元格?indexPath.row始終爲0
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// Configure the cell...
NSDictionary *term = [self.terms objectAtIndex:indexPath.row];
cell.textLabel.text = [term objectForKey:@"content"];
cell.detailTextLabel.text = [term objectForKey:@"created"];
return cell;
}
非常感謝!
編輯:這是我得到的日誌記錄indexPath
2011-11-21 03:07:58.025演示[21269:F803 2個 指標[0,0]
2011-11 -21 03:07:58.027演示[21269:F803] 2個 索引[1,0]
好像所述第一索引更新,而第二不是。
當我登錄indexPath.row,然而
2011-11-21 03:19:40.306演示[21546:F803] 0
2011-11-21 03:19:40.308演示[21546:f803] 0
那麼,我應該使用什麼來獲得遞增的值?
再次感謝您的幫助。
使用'indexPath.section' –