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
Post a Comment