I have an UIViewController
object.
I would like to know when the viewDidLoad
method has been called.
I understand that I can override this method in the subclass and find out when it is called.
Is there another to know when the viewDidLoad
method is called?
Edit-
I have several view controllers that are pushed onto an UINavigationController
.
Some of these view controllers hide the navigation bars. This can be done using the answer given here.
override func viewWillAppear(animated: Bool) {
self.navigationController?.setNavigationBarHidden(true, animated: animated)
super.viewWillAppear(animated)
}
override func viewWillDisappear(animated: Bool) {
self.navigationController?.setNavigationBarHidden(false, animated: animated)
super.viewWillDisappear(animated)
}
At the present, I have repeated this code in a number of view controllers.
I am trying to remove the repetition of code.
One way to do this would be create a super class that contains this code and have the view controllers that hide the navigation bar subclass this super class. However, some of the view controllers that hide the navigation bar descend from UITableViewController
and UICollectionViewController
.
I am trying to create a class that will observe when the viewWillAppear(_:)
and viewWillDisappear(_:)
is called on view controller and then call the method to hide and show navigation bar.