UItableViewCell问题

时间:2014-03-07 12:31:32

标签: iphone uitableview ios7

我正在使用UItableViewController并以编程方式向单元格添加标签,标签从json数组中读取数据,滚动单元格重用并更改标签数据, 有什么办法可以防止这个问题吗?

3 个答案:

答案 0 :(得分:3)

你的问题不明确。!!但根据您的问题,您可能无法为

设置正确的值(数组计数)
    -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

使用“indexPath.row”

在数组中找到确切的索引
    -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

如果您提供代码,您所写的内容可能有助于我们重新纠正

答案 1 :(得分:0)

使用以下方式:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

NSString *CellId = [NSString stringWithFormat:@"CellId%d%d",indexPath.row,indexPath.section];

if (!cell) 
{
    cell = [[[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellId] autorelease];
}

return cell;
}

答案 2 :(得分:0)

不要像代码一样使用它。它用于重新加载数据。

cell = [[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellId];

相关问题