ios - Can't Change Accessory Type From didSelectRowAtIndexPath? -
before post question itself, need state jailbreak app. why i'm writing in "bizarre" folders in filesystem.
let's continue.
here cellforrowatindexpath method:
-(uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *myidentifier = @"plugincell"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:myidentifier]; if (cell == nil) { cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:myidentifier]; } if(indexpath.row == 0) { cell.textlabel.text = @"default"; }else { //get plugin's display name. nsbundle *currentplugin = [[nsbundle alloc] initwithpath:[nsstring stringwithformat:@"/library/cydeswitch/plugins/%@", [plugins objectatindex:indexpath.row - 1], nil]]; cell.textlabel.text = [[currentplugin localizedinfodictionary] objectforkey:@"cfbundledisplayname"]; if(cell.textlabel.text == nil) { //no localized bundle, let's global display name... cell.textlabel.text = [[currentplugin infodictionary] objectforkey:@"cfbundledisplayname"]; } [currentplugin release]; } if([[[cell textlabel] text] isequaltostring:[settings objectforkey:@"plugintoexecute"]]) { cell.accessorytype = uitableviewcellaccessorycheckmark; currentcell = [cell retain]; } return cell; }
like can see, method uses member called currentcell point cell "selected". options table , user should able have 1 cell checkmark accessory icon @ time.
when use selects cell, changing option , checkmark supposed disappear current cell , appear in newly appeared cell. this:
-(void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { [tableview deselectrowatindexpath:indexpath animated:yes]; currentcell.accessorytype = uitableviewcellaccessorynone; [currentcell release]; currentcell = [[self tableview:tableview cellforrowatindexpath:indexpath] retain]; nslog(@"current cell %@", currentcell.textlabel.text); currentcell.accessorytype = uitableviewcellaccessorycheckmark; }
but doesn't work. moment tap cell, checkmark correctly disappears old cell, never shows in new cell.
i know selection work fine because nslog there prints new cell's text fine.
i have tried keeping track of indexpath before, didn't work @ all. when tried using indexpaths instead of pointers cells, when user tapped cell nothing happened @ (at least current approach checkmark disappears old cell).
i think has cellforrowatindexpath because if keep pointing @ cells checkmark disappears, reason when trying change accessory type cell fetched cellforrowatindexpath doesn't seem work @ all.
any appreciated.
typo? try this:
currentcell = [[self.tableview cellforrowatindexpath:indexpath] retain];
Comments
Post a Comment