小编Sim*_*Lee的帖子

indexPath.row始终为0

我正在使用一系列字典填充表视图.解析数组和字典的内容没有问题.但是,该表填充了[数组计数]单元格数,其内容具有数组的索引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;
}
Run Code Online (Sandbox Code Playgroud)

非常感谢!

编辑:这是我记录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

那么我应该使用什么来获得递增的值?

再次感谢您的帮助.

objective-c nsindexpath

12
推荐指数
2
解决办法
1万
查看次数

标签 统计

nsindexpath ×1

objective-c ×1