Closed hallamager closed 6 years ago
Hi @hallamager you want to run an animation when the ViewController is displayed right? The best way to do this is to force the tableView
to reload (or load initially in this case as at that point the cells have not been loaded yet) and then run your animation. I just tested this code on the example app and it works:
override func viewDidLoad() {
super.viewDidLoad()
tableView.reloadData()
let animations = [AnimationType.from(direction: .bottom, offset: 30.0)]
tableView.animateViews(animations: animations)
}
That's perfect thank you!
Also, i’m trying to implement an animation on a collectionView with a delay. However the collectionView flashes quickly and them does the animation.
@hallamager please check #23, UICollectionView
cell reloading works different from UITableView
so you have to implement a workaround for it.
Bit new to swift, this is confusing me a little. I'm trying to do this for viewDidLoad again. This is what i've got;
self.collectionView.performBatchUpdates({ self.collectionView.animateViews(animations: self.animations, delay: 0.3) }, completion: nil)
Right that looks ok but make sure to call collectionView.reloadData()
before that to make sure the cells are loaded.
Same problem still occurs.
I've got;
self.collectionView.reloadData() self.collectionView.performBatchUpdates({ self.collectionView.animateViews(animations: self.animations, delay: 0.3) }, completion: nil)
How can I use an animate a
UITableView
's cells onviewDidLoad()
?