我有一个带动态原型的UITableView。 我实现了下面的代码,所以当我选择一行时,它将被标记,并且之前选择的行将被标记。 但是,例如,我选择的行显示在屏幕的中间,然后当我向上或向下滚动时,另一个单元(位于屏幕的相同中间位置)被标记。总之,每个视图都有一个选中的单元格。 请指教。当你向上或向下滚动时,选择一个UITableViewCell选择在同一位置的其他单元格
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSIndexPath *oldIndexPath = [self.tableView indexPathForSelectedRow];
[self.tableView cellForRowAtIndexPath:oldIndexPath].accessoryType = UITableViewCellAccessoryNone;
[self.tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark;
return indexPath;
}
显示您的代码cellForRowAtIndexPath –