(IOS) When i want to make a button disable in a cell, its make many other disable -
i making ios app. issue when want make button disable in cell, make many other disable. try many issue don't know why. tag of button ok, think don't use sender correctly. code :
- (ibaction) fiyeitpressed:(uibutton*)sender { uibutton *fiyeitbutton = (uibutton*) sender; [fiyeitbutton setenabled:no]; nslog(@"%d",[fiyeitbutton tag]); nsstring *fiyenumberstring = [playlistvote objectatindex:sender.tag]; int fiyeint = [fiyenumberstring intvalue] + 1; fiyenumberstring = [nsstring stringwithformat:@"%d",fiyeint]; [playlistvote replaceobjectatindex:sender.tag withobject:fiyenumberstring]; [self savefortable]; } - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"cell"; playlisttableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier forindexpath:indexpath]; cell.songname.text = [playlistsongtitle objectatindex:indexpath.row]; cell.artistename.text = [playlistsongartist objectatindex:indexpath.row]; cell.numberofvote.text = [playlistvote objectatindex:indexpath.row]; cell.votebutton.tag = indexpath.row; return cell; }
since reusing tableview cells means when start scrolling in tableview, cell disabled button reused , shown. need actively set button enabled or disabled in cellforrowatindexpath.
i suggest keep track of indexes button has been pressed on, , use information determine whether button should enabled or disabled in cellforrowatindexpath method.
Comments
Post a Comment