class FourthViewController : UIViewController {
@IBOutlet weak var previousLabel: UILabel!
@IBOutlet weak var backButton: UIButton!
var delegate: FourthToFirst?
var label = ""
// MARK: - Lifecycle method
override func viewDidLoad() {
super.viewDidLoad()
previousLabel.text = label
let fourthViewController = storyboard?.instantiateViewController(withIdentifier: "FourthViewController") as? FourthViewController
navigationController?.pushViewController(fourthViewController!, animated: true)
}
// MARK: - IBAction
@IBAction func backToFirst(_ sender: Any) {
navigationController?.popToRootViewController(animated: true)
}
实际上,我在fourviewController中是递归运行的(即一次又一次地推动fourViewController,不停地
如果我按了控制器中的后退按钮,则必须返回(即firstviewcontroller)
问题是:
在我的代码中它正在(即不停)
我无法按“后退”按钮返回(即firstviewcontroller)
答案 0 :(得分:0)
navigationController?.popViewController(animated: true)
而不是navigationController?.popToRootViewController(animated: true)
可能是您需要的伴侣。 (基于您刚刚编辑的内容)