tableview約60行の多くの行があり、ユーザーが必要な数の行を使用できるようにしたいcheckとuncheck考えUITableViewCellAccessoryCheckmarkています。問題は、特定の をチェックするとcell、その位置にある他のすべてのセルもチェックされることです。たとえば、行番号 5 をチェックすると、行番号 15、25、35 なども取得されますが、UITableViewCellAccessoryCheckmarkそれが発生することは望ましくありません。チェックされた行は、ユーザーが実際に選択した行のみである必要があります。didSelectRowAtIndexPathメソッドのコードは次のとおりです
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
Materia *current = [Manejador MateriasEnListaAtIndex:indexPath.row ];
if(cell.accessoryType == UITableViewCellAccessoryCheckmark){
cell.accessoryType = UITableViewCellAccessoryNone;
[ManejadorVistas EliminarMateria:current];
}
else{
cell.accessoryType = UITableViewCellAccessoryCheckmark;
[ManejadorVistas AgregarMateria:current];
}
}