【问题标题】:Should I use presentViewController to go back to the first view controller?我应该使用 presentViewController 回到第一个视图控制器吗?
【发布时间】:2019-01-25 21:23:34
【问题描述】:

使用故事板,我以模态方式从 FirstViewController 呈现 SecondViewController。然后,我从 SecondViewController 模态地呈现 ThirdViewController。选择UITableViewCell 后,我需要 ThirdViewController 回到 FirstViewController。我通过使用以下代码实现了这一点。

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

但是,我现在才意识到这可能不是最佳实践,因为这会在堆栈上添加另一个 ViewController。

【问题讨论】:

    标签: ios uiviewcontroller presentviewcontroller


    【解决方案1】:

    最好使用 NavigationViewController 并在您的 viewControllers 中推送和弹出。

    【讨论】:

    • 这也是我的想法,但要确保我没有想太多。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多