代码之家  ›  专栏  ›  技术社区  ›  Curt Rand

我应该使用PresentViewController返回第一个视图控制器吗?

  •  0
  • Curt Rand  · 技术社区  · 6 年前

    使用故事板,我以模态方式呈现FirstViewController中的SecondViewController。然后,我从secondviewcontroller中以模态的方式展示第三视图控制器。我需要ThirdView控制器在选择 UITableViewCell . 我通过使用以下代码实现了这一点。

      let firstViewController = self.storyboard?.instantiateViewController(withIdentifier: "firstViewController") as! FirstViewController
      self.present(firstViewController, animated: true, completion: nil)
    

    然而,我刚刚意识到这可能不是最佳实践,因为这将在堆栈上添加另一个视图控制器。

    1 回复  |  直到 6 年前
        1
  •  0
  •   willow    6 年前

    最好使用navigationviewcontroller并在视图控制器中推送和弹出。