私はちょっと混乱してUINavigationController
スタックです。 rootViewController("ViewController")
からUIViewController("SubmitRequestViewController")
が表示されています。以下はViewControllerは私のrootViewControllerから何度も呼び出されています
私のコードです:
let controller = SubmitRequestViewController.init(nibName: "SubmitRequestViewController", bundle: nil)
self.navigationController?.pushViewController(controller, animated: true)
は今、私はちょうど私のrootViewController
にSubmitRequestViewController
から戻ってくるしようとしています。
//Home Button
@objc fileprivate func backHome() {
let _ = self.navigationController?.popToRootViewController(animated: true)
}
//Back Button
@objc fileprivate func backButton() {
let _ = self.navigationController?.popViewController(animated: true)
}
「SubmitRequestViewController
」にもう一度電話をかけると、2回呼び出されます。
これは継続的に行われています。上記の手順を繰り返すと、複数回呼び出されます。
今、私が得たものは次のとおりです。 -
navigationController.viewControllers.count
continuesly増加しつつあります。
私はnavigationController
にポップアップしようとしていますが、まだ存在しています。
また、私はこれを試してみました: -
self.navigationController?.dismiss(animated: true, completion: nil)
実は、私は私のDrawerViewControllerクラスで通知を発射しています: -
//Submit Request
else if itemArray[indexPath.row].contains("SUBMIT REQUEST") == true {
tableView.deselectRow(at: indexPath, animated: false)
self.dismiss(animated: true, completion: nil)
NotificationCenter.default.post(name: Notification.Name(rawValue : AssessNowKyes.submitRequest), object: nil)
}.
私は私のViewControllerClassでそれを呼び出しています: -
override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(submitRequestClicked), name: Notification.Name(rawValue : AssessNowKyes.submitRequest), object: nil)
}
//Submit Request Clicked
@objc fileprivate func submitRequestClicked() {
let controller = SubmitRequestViewController.init(nibName: "SubmitRequestViewController", bundle: nil)
self.navigationController?.pushViewController(controller, animated: true)
}
私はそれをやっています。私はObserverも削除しなければならないことを知らないのですか?私もそれを試みたので。動いていない。あなたはこの本が間違っ
let controller = SubmitRequestViewController.init(nibName: "SubmitRequestViewController", bundle: nil)
self.navigationController?.pushViewController(controller, animated: true)
メインスレッドでpopviewcontrollerメソッドを実行できますか? – Basheer
let _ =、self.navigationController?.popToRootViewController(animated:true)は必要なものです –
これは、self.navigationController?.popViewController(animated:true)の意味ですか? – kishor0011