iOS-UITableViewCell不';在我选择另一个单元格之前,请不要重新加载
我在重新加载选定单元格时遇到问题。 试图学习教程,但现在遇到了一个奇怪的问题。 我已经列出了一个列表,其中选择一个项目将显示/删除复选标记。 但是,在列表中选择另一个单元格之前,该单元格不会更新 有什么想法吗 我在下面附上了相关的源代码 谢谢,KiOS-UITableViewCell不';在我选择另一个单元格之前,请不要重新加载,ios,objective-c,uitableview,Ios,Objective C,Uitableview,我在重新加载选定单元格时遇到问题。 试图学习教程,但现在遇到了一个奇怪的问题。 我已经列出了一个列表,其中选择一个项目将显示/删除复选标记。 但是,在列表中选择另一个单元格之前,该单元格不会更新 有什么想法吗 我在下面附上了相关的源代码 谢谢,K - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"ListPrototypeCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
XYZToDoItem *toDoItem = [self.toDoItems objectAtIndex:indexPath.row];
cell.textLabel.text = toDoItem.itemName;
if(toDoItem.completed) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
} else {
cell.accessoryType = UITableViewCellAccessoryNone;
}
return cell;
}
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:NO];
XYZToDoItem *toDoItem = [self.toDoItems objectAtIndex:indexPath.row];
toDoItem.completed = !toDoItem.completed;
[tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
}
您意外地实现了
dideselectrowatindexpath
而不是didSelectRowAtIndexPath您意外地实现了dideselectrowatindexpath
而不是didSelectRowAtIndexPath您的问题是您没有使用dideselectrowatindexpath
,而是didSelectRowAtIndexPath
所以现在每次你取消选择你的单元格你都会更新你的单元格:)你的问题是你没有使用didSelectRowAtIndexPath
但是didSelectRowAtIndexPath
所以现在每次你取消选择你的单元格你都会更新你的单元格:)