I am having a multiple UIViewController
embedded in a UITabbarController
.
These are connected by Relationship Segues.
The starting point, VC1
initially loads data and is then processed to a "detail" view.
Whenever I change tabs and go back to VC1
, the application gets stuck, as viewDidLoad
is not called.
Is there a way to trigger a function each time VC1
is segued to?
the application gets stuck, as viewDidLoad is not called
The application is not stuck. It is working perfectly. viewDidLoad
is called when a view controller is created and loads its view. That only happens once in the life of the view controller. When you leave a view controller and come back to it, it is still there (i.e. it is not being created from scratch), so naturally viewDidLoad
is not called.
If your goal is to hear about the fact that the tab bar controller is switching to VC1, give the tab bar controller a delegate and implement tabBarController(_:didSelect:) or similar.
Even better, configure things so that there is no need to do this. If there is common data that is accessed by both view controllers, architect things so that a view controller sends new data up to a data controller and the data controller broadcasts news of the change down to all view controllers that need to know this.