ios - Cell deletion animation not kicking in from didSelectRowAtIndexPath: -
basically, when select specific row, wand rows table view removed. have following code:
-(void)removerows:(int)i { nsindexpath *ip = [nsindexpath indexpathforrow:i insection:0]; uitableviewcell *cell = [_table cellforrowatindexpath:ip]; cgrect newframe; if(i%2==0){ newframe = cell.frame; newframe.origin.x = -[uiscreen mainscreen].bounds.size.width; }else{ newframe = cell.frame; newframe.origin.x = [uiscreen mainscreen].bounds.size.width; } [uiview animatewithduration:0.2 delay:0 options:0 animations:^{cell.frame = newframe;} completion: ^(bool finished){ if(i == 0){ [datasource removeallobjects]; [_homescreenview.proustpacks reloaddata]; } }]; }
this method called each row in reverse order. works great if use delete button (which not part of tableview), want same animation , action when user taps specific cell, like:
- (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { if([(something*)[datasource objectatindex:indexpath.row] iswhatiwant]){ [nstimer scheduledtimerwithtimeinterval:0.2 target:self selector:@selector(remove) userinfo:nil repeats:no]; [nstimer scheduledtimerwithtimeinterval:0.4 target:self selector:@selector(gotonext:) userinfo:nil repeats:no]; } }
where "gotonext:" pushes next controller navigationcontroller , removepacks is:
-(void)remove{ int aux = _datasource.count -1; for(int i=aux;i>=0;i--){ [self removerows:i]; } }
i think can use answer:
https://stackoverflow.com/a/22085713/661749
basically need give indexpaths remove function , select animation want. don't forget change collection well.
Comments
Post a Comment