ios - Add and remove target actions for UIButton in UITableViewCell -


what best way add , remove target actions uibutton in uitableviewcell.

for each row of have different button action based on row index. show please tell me add add target button , remove target button.

i asking delegate , data source used.

in

-(uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {     [cell.btn1 removetarget:self action:@selector(action1:) forcontrolevents:uicontroleventtouchupinside];     [cell.btn1 removetarget:self action:@selector(action2:) forcontrolevents:uicontroleventtouchupinside];      cell.btn1.tag = indexpath.row;     if(indexpath.row%2)    {         [cell.btn1 addtarget:self action:@selector(onbtnweighin:) forcontrolevents:uicontroleventtouchupinside];    }    else{         [cell.btn1 addtarget:self action:@selector(onbtnviewtable:) forcontrolevents:uicontroleventtouchupinside];    }  } 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -