UITableviewcell中的标签值在滚动时会发生变化。我在网上查了几个答案。但是我找不到答案。这是我的代码
-(void)configureCell:(ScoreViewCell *)cell atIndexPath:(NSIndexPath *)indexPath{
Player *player = [self.players objectAtIndex:indexPath.row];
cell.nameLabel.text = player.playerName;
cell.totalScoreLabel.text = [NSString stringWithFormat:@"%@",player.currentScore];
[cell.enterScoreField setTag:indexPath.row];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *cellIdentifier = @"addScoreCell";
ScoreViewCell *cell = (ScoreViewCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if ((cell == nil) || (![cell isKindOfClass: [ScoreViewCell class]])) {
cell = [[ScoreViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
[self configureCell:cell atIndexPath:indexPath];
return cell;
}
答案 0 :(得分:0)
检查代码中currentScroe
的设置方式。检查它是否在其他地方被修改。我怀疑Player对象本身的currentScore是0。