iphone - Trouble with UITableViewCellAccessory (Checkmark/None toggle) -
edit
don't feel idiot. until now, haven't been paying attention whether or not cell gets checkmark. somehow, had uitableviewcellaccessorycheckmark
, uitableviewcellaccessorynone
flipped, turning off when wanted on , turning on when wanted off. reading code debugging...
/edit
below code having trouble with.
tableview:didselectrowatindexpath:
if (i.need == 0) { // item not needed - hide (#) , turn on checkmark i.need = 1; cell.textlabel.text = [nsstring stringwithformat:@"%@", i.name]; cell.accessorytype = uitableviewcellaccessorynone; } else if (i.need < 0) { // item not needed - hide (#) , turn on checkmark i.need = -i.need; cell.textlabel.text = [nsstring stringwithformat:@"%@", i.name]; cell.accessorytype = uitableviewcellaccessorynone; } else { // item not needed - show (#) , turn off checkmark i.need = -i.need; cell.textlabel.text = [nsstring stringwithformat:@"%@ (%d)", i.name, -i.need]; cell.accessorytype = uitableviewcellaccessorycheckmark; }
the following making mistake.
tap row checkmark: (#) hidden, checkmark removed tap row without checkmark: (#) shown, checkmark not set until next tap
i'm not sure how made mistake of not connecting comment , accessory, there go. should like:
if (i.need == 0) { // item not needed - hide (#) , turn on checkmark i.need = 1; cell.textlabel.text = [nsstring stringwithformat:@"%@", i.name]; cell.accessorytype = uitableviewcellaccessorycheckmark; } else if (i.need < 0) { // item not needed - hide (#) , turn on checkmark i.need = -i.need; cell.textlabel.text = [nsstring stringwithformat:@"%@", i.name]; cell.accessorytype = uitableviewcellaccessorycheckmark; } else { // item not needed - show (#) , turn off checkmark i.need = -i.need; cell.textlabel.text = [nsstring stringwithformat:@"%@ (%d)", i.name, -i.need]; cell.accessorytype = uitableviewcellaccessorynone; }
Comments
Post a Comment