如果我 return 返回 Swift 如何在不重新加载视图的情况下浏览视图

How to go through Views without reload them again if I return back Swift

我有 ViewController1 和 ViewController2 。当我单击 ViewController1 上的按钮时应该转到 ViewController2,当按下自定义后退按钮时应该 return 到 ViewController1 而无需重新加载其内容,例如:- 如果我在 ViewController1 的文本文件中键入内容,它应该保持原样。 有谁知道这个的解决方案吗?

1- 加载视图控制器 1

2- 您的自定义按钮应该在视图控制器 1 的顶部显示 ViewController 2(本机 self.present 执行此操作,请注意它显示在 VC1 的顶部,因此 VC1 仍然存在)

3- 您在 View Controller 2 上的后退按钮关闭 View Controller 2 并且您 return 到 View Controller 1 与您离开时一样

希望对您有所帮助!

viewcontoller1 button click code...

@IBAction func Parsent(sender: AnyObject) {
    let secondVC = self.storyboard?.instantiateViewController(withIdentifier: "Identifier" as! ViewController2
    let navigationVC = UINavigationController(rootViewController: secondVC)
    self.present(navigationVC, animated: true, completion: nil)
 }

ViewController2 button code here..

@IBAction func Dismiss(sender: AnyObject) {
    self.dismissViewControllerAnimated(true, completion: nil)
 }