iphone - Detecting which button clicked in prototype cell in ios -
i created 1 prototype cell. cell has 1 label , 1 button. have given tag's both. want detect button clicked 10 cells.
previously differentiating based on tag. how prototype cell.
my code cell creation follows:
- (uitableviewcell *) tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:@"cellidentifier"]; if (cell == nil) { cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstylesubtitle reuseidentifier:@"cellidentifier"]; } uibutton *stopstartbutton = (uibutton *)[cell viewwithtag:103]; uilabel *charginglabel = (uilabel *)[cell viewwithtag:102]; } -(ibaction)stopstartbuttonclicked:(id)sender { nslog(@"button clicked"); }
you can use button.titlelabel.tag
differentiate button , @ action time can compare same tag.
second option button action. can append event provide information regarding button.
for example set
stopstartbutton.titlelabel.tag=1; -(ibaction)stopstartbuttonclicked:(id)sender { nslog(@"button clicked %d",sender.titlelabel.tag); }
Comments
Post a Comment