ios - How to delete the tableview cell without pressing delete button? -


 - (nsarray *)tableview:(uitableview *)tableview editactionsforrowatindexpath:(nsindexpath *)indexpath  {     uitableviewcell *cell = [tableview1 cellforrowatindexpath:indexpath];     uitableviewrowaction *flagaction = [uitableviewrowaction rowactionwithstyle:uitableviewrowactionstyledefault title:@"delete" handler:^(uitableviewrowaction *action, nsindexpath *indexpath) {      [tabledata removeobjectatindex:indexpath.row];     nslog(@"indexpath %ld",indexpath.row);     [tableview deleterowsatindexpaths:@[indexpath] withrowanimation:uitableviewrowanimationautomatic]; }];     return @[ flagaction]; } 

you can add swipe gesture table , delete row shown following.

- (void)viewdidload {     uiswipegesturerecognizer *gesturedeleterow = [[uiswipegesturerecognizer alloc] initwithtarget:self          action:@selector(cellswipe:)];     gesturedeleterow.direction = uiswipegesturerecognizerdirectionright;     [tableview addgesturerecognizer:gesturedeleterow]; }  //swipe handler method -(void)cellswipe:(uiswipegesturerecognizer *)gesture {     cgpoint location = [gesture locationinview:tableview];     nsindexpath *swipedindexpath = [tableview indexpathforrowatpoint:location];     //delete row…     [array removeobjectatindex: swipedindexpath.row];     [tableview deleterowsatindexpaths:[nsarray arraywithobjects:swipedindexpath, nil] withrowanimation:uitableviewrowanimationleft]; } 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -