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

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -