Proper way to restore animations in UITableViewCell

Viewed 46

My cell has 2 types of animation

  • UIView.animate + CGAffineTransform
  • layer.add + CABasicAnimation

It's on a table which is part of UITabBarController.

Issues:

  1. Moving between tabs and returning back does stop animation
  2. Scrolling up/down so cell gets hidden and returned - does stop animation

How I thought to solve it - through prepareforreuse in my cell. But problem with that is after some testing with setting tag to a cell in its init - apparently dequeue returns 2 different cells. For example if tags are 1 and 2 - when I move to tab#2 and back to tab#1 I'll get cell with tag 1, repeat - tag 2, repeate - tag 1. Very confused with this...

So my current idea is to maybe move if cell has animation or not and what type of animation into outside vc and pass in cellforrow / willdisplay cells. Am I correct in that thinking?

Or perhaps there is a better way to restore animations in a cell?

0 Answers
Related