ios - UITableview Insert/Delete -
i having 1 number of section base tableview in plus button add new item in tableview.
while try add or delete section tableview , reload tableview blink old record many times , add or delete section.
here code.
-(void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { symboltableviewcell *cell = [tableview cellforrowatindexpath:indexpath]; if ([selectindexpath containsobject:[nsnumber numberwithint:(int)indexpath.section]]) { [selectsymbol removeobject:cell.lblsymbol.text]; [selectindexpath removeobject:[nsnumber numberwithint:(int)indexpath.section]]; } else { nsstring *strr = cell.lblsymbol.text; [selectsymbol addobject:strr]; [selectindexpath addobject:[nsnumber numberwithint:(int)indexpath.section]]; } [tbldetail reloaddata]; }
what issue?
try following code may helps you
-(void)tableview:(uitableview *)tableview didselectrowatindexpath: (nsindexpath *)indexpath { symboltableviewcell *cell = [tableview cellforrowatindexpath:indexpath]; if ([selectindexpath containsobject:[nsnumber numberwithint:(int)indexpath.section]]) { [tbldetail beginupdates]; [selectsymbol removeobject:cell.lblsymbol.text]; [selectindexpath removeobject:[nsnumber numberwithint:(int)indexpath.section]]; [tableview deleterowsatindexpaths:@[indexpath] withrowanimation:uitableviewrowanimationfade]; [tableview endupdates]; } else { nsstring *strr = cell.lblsymbol.text; [tbldetail beginupdates]; [selectsymbol addobject:strr]; [selectindexpath addobject:[nsnumber numberwithint:(int)indexpath.section]]; [tableview reloadrowsatindexpaths:@[indexpath] withrowanimation:uitableviewrowanimationfade]; [tableview endupdates]; } }
Comments
Post a Comment