ios - UITableView - Check if Cell checkmark -
in uitableview, user can check or not check cell. how can figure out, witch checked , save in array?
with following code, can check cell:
-(void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath{ uitableviewcell *cell = [tableview cellforrowatindexpath:indexpath]; if ([cell accessorytype] == uitableviewcellaccessorynone) { [cell setaccessorytype:uitableviewcellaccessorycheckmark]; } else { [cell setaccessorytype:uitableviewcellaccessorynone]; } [tableview deselectrowatindexpath:indexpath animated:no]; }
don't check checkmark accessory view of cells. cells being reused , mess logic.
instead, keep mutable set of objects being presented cells 'selected' aka checked.
when user taps cell can toggle membership of presented object in mutable set , update checkmark appropriately.
Comments
Post a Comment