ios - 为什么我的 unwind segue 回溯得太远了?

标签 ios xcode swift unwind-segue

我正在尝试为我的应用程序的注册过程创建 Controller 架构。下面是当前状态的图像:

Controller Architecture

该应用程序第一次从登录页面启动,如果用户点击“注册”,导航 Controller 将通过 self.presentViewController 模态呈现。导航 Controller 然后推送通过 View Controller ,然后推送到第二个 View Controller 。在第二个 View Controller 上,用户必须先按“Go”以模态导航到请求附加信息的 View Controller ,然后再继续注册过程。一旦用户在这个模态呈现的 Controller 上输入了额外的信息,用户按下“返回”以通过展开转场返回到第二个 View Controller 。

但是,当按下此按钮时,展开转场返回到第二个 View Controller ,但随后立即返回到“登录”页面。看起来 unwind segue 弹出所有模态呈现的 View ,即使 unwind 函数嵌套在第二个 View Controller 中。

这是怎么回事,展开到第二个注册页面的解决方案是什么?

最佳答案

我遇到了同样的问题,这通常是由以下原因之一引起的:

  1. 使用已弃用的 segue
  2. 在用于展开的@IBAction 方法中调用 viewController.dismissViewControllerAnimated。
  3. 将@IBAction 用于在错误的 Controller 中展开。 @IBAction 应该在您要放松到的 Controller 中。

解除segue的步骤

  1. 在 SecondSignupController 中创建一个 @IBAction 方法,此方法将在展开时调用。此方法应将 UIStoryboardSegue 作为参数示例 -> @IBAction func onUnwindFromModalPage(segue:UIStoryboardSegue){}。此方法的主要目的是传回数据(如果有),否则您可以将其留空。

  2. 按住 Control 从“返回”按钮拖动到 Storyboard中模态呈现 Controller 中的退出符号。退出符号是选择 Controller 时 Controller 顶部的最后一个符号。这将向您显示您可以选择用于展开的@IBActions 列表。选择您在 SecondSignUpController 中创建的方法。

关于ios - 为什么我的 unwind segue 回溯得太远了?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33181577/

相关文章:

ios - 无法从IOS中的plist文件读取字典数据

Swift 泛型与任何泛型

swift - 奇怪的 `Fatal error: Unexpectedly found nil` 但可选 DOES 有一个值

ios - React Native Expo 弹出应用程序,无法从设备获取推送 token

ios - Apple 的可下载/可执行代码限制如何与在 UIWebView 中使用 HTML5 和 Javascript 相符?

android - 互联网连接丢失时,xmpp ejabberd 在线离线状态问题

ios - 显示不正确值的自定义 UITableViewCell

xcode - 验证 GateKeeper (Sierra) 的 OSX 应用程序签名时出现问题 ["the code is valid but does not seem to be an app"]

python - PyObjC + Python 3.0 问题

ios - 无法为类似 Pinterest 的 iOS 应用程序加载 [UIButton] 数组的所有项目