ios4 - UITableviewCell with RemoveButton -
i have 1 tableview in added uibutton each tableviewcell named remove when click remove button appropriate cell data remove tableview
and added uibutton programmatically
now want perform remove option.
thanks in advance....
try one:
- (uitableviewcell *)tableview:(uitableview *)atableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *s = @"cell"; uitableviewcell *cell = (uitableviewcell *)[tableview dequeuereusablecellwithidentifier:s]; asyncimageview *asyncimage; uibutton *button = nil; if ( cell == nil ) { cell = [[[uitableviewcell alloc]initwithreuseidentifier:s] autorelease]; uibutton *removebtn = [uibutton buttonwithtype:uibuttontypecustom]; [button addtarget:self action:@selector(remove:) forcontrolevents:uicontroleventtouchupinside]; …. [cell addsubview:button]; } ….. return cell; } -(void)remove:(uibutton*)btn{ uitableviewcell *cell = (uitableviewcell *)btn.superview; nsindexpath* index = [self.tableview indexpathforcell:cell]; [peoplelist removeobjectatindex:index.row]; [self.tableview deleterowsatindexpaths:[nsarray arraywithobject:index] withrowanimation:uitableviewrowanimationright]; }
Comments
Post a Comment