選択したセルのリロードに問題があります。チュートリアルに従おうとしていますが、奇妙な問題で立ち往生しています。アイテムを選択するとチェックマークが表示/削除されると思われるリストを作成しました。ただし、リスト内の別のセルを選択するまで、セルは更新されません。
何か案は?
関連するソースコードを以下に添付しました。
ありがとう、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];
}