Control insertRowsAtIndexPath animation speed in uitableview

I used insertRowsAtIndexPath instead of reloadData. At the first load, the animation is too fast, because the number of lines is large.

Can I control insertRowsAtIndexPath speed animations?

Thanks.

+6
source share
3 answers

I think it’s impossible to control the speed of the animation.

Maybe you can use scrollToRowAtIndesPath instead.

0
source

Undo insertRowsAtIndexPaths and add custom animation as you like with a delay.

 - (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation: (UITableViewRowAnimation)animation { for (NSIndexPath *indexPath in indexPaths) { UITableViewCell *cell = [self cellForRowAtIndexPath:indexPath]; [cell setFrame:CGRectMake(320, cell.frame.origin.y, cell.frame.size.width, cell.frame.size.height)]; [UIView beginAnimations:NULL context:nil]; [UIView setAnimationDuration:1]; [cell setFrame:CGRectMake(0, cell.frame.origin.y, cell.frame.size.width, cell.frame.size.height)]; [UIView commitAnimations]; } } 
0
source

Absolutely untested, but you can try this for a five-second animation:

 [UIView animateWithDuration:5. animations:^(void){ [_tableView insertRowsAtIndexPath:... animated:NO]; }]; 
-3
source

Source: https://habr.com/ru/post/911733/


All Articles