Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/95.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS-UITableViewCell不';在我选择另一个单元格之前,请不要重新加载_Ios_Objective C_Uitableview - Fatal编程技术网

iOS-UITableViewCell不';在我选择另一个单元格之前,请不要重新加载

iOS-UITableViewCell不';在我选择另一个单元格之前,请不要重新加载,ios,objective-c,uitableview,Ios,Objective C,Uitableview,我在重新加载选定单元格时遇到问题。 试图学习教程,但现在遇到了一个奇怪的问题。 我已经列出了一个列表,其中选择一个项目将显示/删除复选标记。 但是,在列表中选择另一个单元格之前,该单元格不会更新 有什么想法吗 我在下面附上了相关的源代码 谢谢,K - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *

我在重新加载选定单元格时遇到问题。 试图学习教程,但现在遇到了一个奇怪的问题。 我已经列出了一个列表,其中选择一个项目将显示/删除复选标记。 但是,在列表中选择另一个单元格之前,该单元格不会更新

有什么想法吗

我在下面附上了相关的源代码

谢谢,K

- (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
所以现在每次你取消选择你的单元格你都会更新你的单元格:)