Resetting table animation

Therefore, when the user clicks on a cell in my table, I don’t actually click on the new view controller, I just reload the data inside this tableView.

However, I want to get an effect similar to how it would look if I clicked on a new view controller.

Does anyone know how I can hide old content from old content from the screen and new content to the screen for the entire table?

+7
source share
2 answers

Depending on how many sections you have, you can use - (void)reloadSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation

So you can do something like this:

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:YES]; [tableView reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0,[self numberOfSectionsInTableView])] withRowAnimation:UITableViewRowAnimationRight]; } 
+13
source

Simple animation

  func animateTable() { self.reloadData() let cells = self.visibleCells let tableHeight: CGFloat = self.bounds.size.height for i in cells { let cell: UITableViewCell = i as UITableViewCell cell.transform = CGAffineTransform(translationX: 0, y: tableHeight) } var index = 0 for a in cells { let cell: UITableViewCell = a as UITableViewCell UIView.animate(withDuration: 1.5, delay: 0.05 * Double(index), usingSpringWithDamping: 0.8, initialSpringVelocity: 0, options: UIViewAnimationOptions.curveLinear, animations: { cell.transform = CGAffineTransform.identity }, completion: nil) index += 1 } } 
0
source

All Articles