この質問は以前に尋ねられたことは知っていますが、それらの間に混乱があります。セル上に複数のチェックマークが必要なので、そのセルのチェックマークをもう一度クリックすると、その選択されたセルのチェックマークをなしに設定する必要があります。私はこれを試したが、選択されたセルを再びクリックすると、選択されたセルはすべて選択されない。私はこれを試した。テーブルビューのセルでチェックボックスを取得する
- (UITableViewCell)tableView:(UITableView)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
myTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"myTableViewCell" forIndexPath:indexPath];
cell.accessoryType = UITableViewCellAccessoryNone;
return cell;
}
とdidSelectRowAtIndexPath
- (void)tableView:(UITableView)tableView didSelectRowAtIndexPath:(NSIndexPath )indexPath
{
myTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"myTableViewCell" forIndexPath:indexPath];
if (cell.accessoryType == UITableViewCellAccessoryNone) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
else
{
cell.accessoryType = UITableViewCellAccessoryNone;
}
}
とdidDeselectRowAtIndexPath
-(void)tableView:(UITableView)tableView didDeselectRowAtIndexPath:(NSIndexPath)indexPath
{
myTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"myTableViewCell" forIndexPath:indexPath];
if (cell.accessoryType == UITableViewCellAccessoryNone) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
else
{
cell.accessoryType = UITableViewCellAccessoryNone;
}
}
中で助けてください。
ただ、すべての権利didDeselectをtuseする必要はありません 'cellForRowAtIndexPath' –
を試してみてください選択されたインデックスを配列に格納する必要があります。indexPath.rowでチェックする必要があります。cellforrowIndexPathで同じかどうかを確認してください。 –
を使用して... /コメントメソッド' didDeselectRowAtIndexPath'を削除して..あなたはdidSelectRowAtIndexPathとdidDeselectRowAtIndexPathメソッド内で 'dequeueReusableCellWithIdentifier'を使用している理由 –