としては、ルートビューコントローラ 除い公式文書に"Pushing and popping stack items"
func popToRootViewControllerAnimated(_ animated: Bool) -> [UIViewController]?
ポップスタック上のすべてのビューコントローラを説明し、表示を更新します。あなたがrootViewControllerに行く必要があるときに説明できる
@IBAction func backToRootButton(sender: UIButton) {
navigationController?.popToRootViewControllerAnimated(true)
}
この画像を::
このコードを使用すると、あなたのnavigationController 戻るボタンをカスタマイズすることができます下のあなたは、単にでそれを使用することができます
:
override func viewDidLoad {
super.viewDidLoad()
self.navigationItem.hidesBackButton = true
let newBackButton = UIBarButtonItem(title: "Back", style: UIBarButtonItemStyle.Bordered, target: self, action: "back:")
self.navigationItem.leftBarButtonItem = newBackButton;
}
func back(sender: UIBarButtonItem) {
// Perform your custom actions
// ...
// Go back to the previous ViewController
//self.navigationController?.popViewControllerAnimated(true)
// ..or go back to the rootViewController
self.navigationController?.popToRootViewControllerAnimated(true)
}
あなたは単純に前のviewControllerにポップするか、ルートに直接行くか、今のところあなたのスタックの深さやtopViewControllerに依存する必要があるかどうかを決めることができます。
「ゆるやかなセグ」をチェックすることができます –