Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to override viewWillDisappear in Swift3

Tags:

swift

swift3

I'm Trying to hide the first navigation bar and show all the others, so I used:

override func viewWillAppear(_ animated: Bool) {
    // Hide the navigation bar on the this view controller
    self.navigationController?.setNavigationBarHidden(true, animated: true)
}

override func viewWillDisappear(_ animated: Bool) {
    // Show the navigation bar on other view controllers
    self.navigationController?.setNavigationBarHidden(false, animated: true)
}

what I need now is to call the super methods: super.viewWillAppear(animated) and super.viewWillDisappear(animated), but I don't know where or how, any suggestions?

like image 941
Mzoch Avatar asked Oct 31 '16 17:10

Mzoch


1 Answers

Your code will look like

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    // Hide the navigation bar on the this view controller
    self.navigationController?.setNavigationBarHidden(true, animated: true)
}

override func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(animated)
    // Show the navigation bar on other view controllers
    self.navigationController?.setNavigationBarHidden(false, animated: true)
}
like image 187
Karun Kumar Avatar answered Nov 15 '22 11:11

Karun Kumar