gpt4 book ai didi

iOS Storyboard : How to segue to the second view with a back button to the first view, 但不显示第一个 View

转载 作者:行者123 更新时间:2023-11-28 21:57:18 24 4
gpt4 key购买 nike

这是我的 Storyboard配置:

导航 Controller -> View Controller A -> 推送 -> View Controller B
^
|
模态
^
|
View Controller C

我想要实现的目标:当在 View C 中按下按钮时,将直接以模态方式打开 View B(不显示 View A 的任何部分)。此外, View B 将有一个返回 View A 的导航后退按钮。

为了实现这一点,

  • 我设置了插图 Storyboard。
  • 我在 View C 和 View A/B 的导航 Controller 之间创建了一个连接。
  • 在 View Controller C 的“prepareForSegue”方法中,我获得了一个 View Controller A 的实例作为导航中的第一个元素。在本例中,我设置了一个变量,例如“directlyProceedToViewB=YES”。
  • 在 View Controller A 的 viewDidLoad 方法中,我检查变量“directlyProceedToViewB”,如果是,我调用“performSegueWithIdentifier”以转至 View B

结果是,首先以模态方式打开 View A,并在显示它很短的时间后,以推送动画打开 View B( View B 可以导航回 View A,这很好)。但我根本不想显示 View A。我怎样才能做到这一点?

编辑:

为了更好地可视化,我添加了一个屏幕截图,其中包含更多示例案例以支持:

enter image description here

以下是我想支持的一些案例:

  • 我们可以从 ViewC 开始,点击“Modally Display B”打开 ViewB,然后点击“Back to A”导航回 ViewA,然后点击 ViewA 上的“Dismiss Modal”返回 ViewC
  • 我们可以从 ViewD 开始,点击“Modally Display A”打开 ViewA,然后点击“PushB”打开 ViewB,然后在 A 和 B 之间来回切换,然后以模态方式关闭到 ViewD。

最佳答案

首先,一些更正:那些不是 View 而是 View Controller 。 “ View A”没有被插入 UINavigationController 但它是根。

在那之后,我建议将“ View C”中的转场设为展开转场,并通过使用 [[self navigationController] 推送“ View B”在“ View A”中实现 IBAction pushViewController:bViewController animated:NO].

编辑(添加一些细节):

我假设在 ViewControllerAviewWillAppear 中,您以非动画方式呈现 ViewControllerC
ViewControllerA 中实现类似 (IBAction)unwindAndThenGoToB:(UIStoryboardSegue *)segue 的展开操作。
在 Storyboard中,将 ViewControllerC 中的按钮连接到 Exit 图标,然后选择之前定义的方法。
然后用我之前写的推送调用来实现这个方法。
ps:Apple 网站上有很多文档。

关于iOS Storyboard : How to segue to the second view with a back button to the first view, 但不显示第一个 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26116769/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com