ios - Show the progressBar that correspond to row of TableView when click with Custom TableViewCell -


i stuck few hours problem. have 3 rows in tableview. use custom cell contained 1 button , 1 progressbar. problem when click on button @ first or second row, progressbar show @ third row. don't know why. want show progressbar correspond row clicked.

 @interface viewcontroller_ ()  {       customviewcell  *cell;   }  @end   - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {      static nsstring *cellidentifier = @"cell";     cell = (customviewcell*)[tableview dequeuereusablecellwithidentifier:cellidentifier];     if (cell==nil) {        nsarray *nib;        nib = [[nsbundle mainbundle] loadnibnamed:@"issueviewcell" owner:self options:nil];        (id oneobject in nib)           if ([oneobject iskindofclass:[customviewcell class]])                 cell = (customviewcell *)oneobject;     }      cell.progressbar.hidden = yes;     [cell.downloadbutton settitle:@"download" forstate:uicontrolstatenormal];     [cell.downloadbutton addtarget:self action:@selector(downloadbuttoncliked:) forcontrolevents:uicontroleventtouchupinside];  }  -(void) downloadbuttoncliked:(uibutton *)sender{        nslog(@"called when press");       cell.progressbar.hidden = no; } 

you not getting cell in right way. cell instance last cell loaded table view.

you should remove cell reference, don't need it.

you can change code this:

-(void) downloadbuttoncliked:(uibutton *)sender{       nslog(@"called when press");       customviewcell *buttoncell = (customviewcell*) sender.superview.superview;       //if add button cell view should call sender.superview;       buttoncell.progressbar.hidden = no; } 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -