Search code examples
swiftanimationviewwillappeartabbarcontroller

Swift viewWillAppear not being called first time usingTabBarController


So i have a tab bar controller and when I select into the second tab it brings me to a table view controller. I have it setup so that when the viewWillAppear it animates the cells in. The problem I am having is that the first time I go into that view, everything is stationary, but if i go to another tab and come back, everything animates perfectly.

How can I get it to animate in the first time I go to the tab as well?

I have not included code because I do not think it will help answer the question.

Edit* I can go to the tab as many times as I want and it will animate each time, but will never animate on the first load of the app.


Solution

  • I had a very similar issue with viewDidAppear. My problem was that I called the viewDidAppear function in the TabBarController to do some stuff but forgot to call super.viewDidAppear(true) in this Method. Because of that the viewDidAppear of the child wasn't called. After I added it everything works like a charm.

    So be sure to add super.viewDidAppear(true) or in your case super.viewWillAppear(true) in the TabBarController. Maybe it helps