我認爲你的方法已經正確。你只需要知道代碼的放置位置。嘗試下面的代碼。
代碼視圖控制器1
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.navigationBarHidden = true;
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
self.navigationController?.navigationBarHidden = true;
}
@IBAction func buttonTapped(sender: UIButton) {
self.performSegueWithIdentifier("goToScreen2", sender: self)
}
}
代碼視圖控制器2
import UIKit
class ViewController2: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
self.navigationController?.setNavigationBarHidden(false, animated: true)
}
}
更新答:
我能夠用取消隱藏導航欄下面碼。實施
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.navigationBarHidden = true;
}
@IBAction func buttonTapped(sender: UIButton) {
self.navigationController?.setNavigationBarHidden(false, animated: true)
}
屏幕截圖: -
什麼控制器或控制器在這些語句,你在哪裏給他們打電話?你如何加載屏幕進入屏幕? – rdelmar 2014-09-11 01:56:53