2016-10-31 48 views
2

我試圖隱藏第一導航欄並顯示所有其他人,所以我用:如何重寫viewWillDisappear在Swift3

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) 
} 

我現在需要的是調用父類的方法:super.viewWillAppear(animated)super.viewWillDisappear(animated) ,但我不知道在哪裏或如何,有什麼建議?

+1

你已經在你的問題正確的代碼。只需將相應的調用添加到相應方法內的'super.view ...'。 – rmaddy

回答

5

您的代碼看起來像

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) 
}