swift - 在 `kind` 和 "Show": why does the change not take effect when running the simulator? 之间更改 Storyboard segue "ShowDetail"

标签 swift ios9 xcode7

首先,请注意,这不是关于“如何完成我的应用程序?”“为什么我的应用程序无法运行?” 的问题,而是涵盖我在玩一个简单的应用程序时偶然发现的一个问题,我无法为我的世界解释。也许 SO 的某个人可以解释为什么会出现这个明显的问题。


为了学习,我一直在玩一个简单的应用程序,该应用程序由嵌入在 Navigation Controller 中的 UITableViewController 组成。从 TableView 单元格(UITableViewCell 的子类)可以导航到一个简单的 UIViewController。请参阅下面的应用程序 Storyboard概述,请注意,这显示了在 TableView 单元格与 View Controller 之间设置 segue 转换之前应用程序的状态(开发)。

App overview, Storyboard

现在,在我的应用程序中,我测试了 TableView 单元格和 View Controller 之间的两种不同类型的转场,即

  1. 从单元格到 View Controller 的“显示”转场,as can be seen in this gif .
  2. 从单元格到 View Controller 的“ShowDetail”转场,as can be seen in this gif .

基于 Apple documentation on storyboard segues ,我希望在运行该应用程序时,我的应用程序的 View Controller 部分出现以下行为:

  • 通过“Show”segue, View Controller 场景将显示一个导航 Controller 栏,在场景的左上角(栏内)包含一个默认的“后退”按钮。让我们从这里开始将其表示为行为 (A),并且 see this image for visualisation of it .
  • 使用“ShowDetail”segue,将不会出现导航栏。从这里开始,我们将其表示为行为 (B),并且 see this image for visualisation of it .

上述情况 1. 和 2. 分别产生了它们的预期结果,即行为 (A) 和 (B)。

现在我无法解释的部分:

  1. 我将 segue 设置为“Show”,然后在属性检查器中将 segue 更改为“ShowDetail”类型,as can be seen in this gif .更改后, Storyboard 中的一切看起来都很好( View Controller 中没有导航 Controller 栏),但是在运行应用程序时,我仍然得到行为 (A),即“显示”segue 的预期行为。
  2. 如果我反之亦然;创建一个“ShowDetail”转场并通过属性检查器(as can be seen in this gif)更改为“Show”,我得到同样的意外(对我来说)行为,即行为(B),即“ShowDetail”转场预期的行为(没有导航 Controller 栏)

我还可以通过记录以下 bool 值来跟踪同样的意外行为:

// In the ViewController code (ViewController.swift)
let presentingViewIsNavigationController = 
    presentingViewController is UINavigationController
  • 上面的情况 1(使用“Show”segue 而不是更改它)如预期的那样产生 false(此处显示的 View 是 UITableViewController,并且这和UIViewController 包裹在导航 Controller 中)。
  • 如预期的那样,上述情况 2 产生 true(导航 Controller 是 UIViewController 的呈现 View )。
  • 情况 3. 上面的结果出乎意料地是 false
  • 情况 4. 出乎意料地,上述情况 true

问题:为什么在模拟器中运行应用程序时,在属性检查器中执行的 segue 类型“Show”与“ShowDetail”之间的更改似乎没有生效?

我在模拟器中运行 Xcode 7.2 和 iOS 9.2(模拟 iPhone 6s plus)。

最佳答案

我在测试时发现的一个转场问题是,当您更改转场类型时,action 属性不会改变:

<segue destination="YYV-02-abX" kind="show" identifier="segueshow" id="X7i-33-rvh"/>
<segue destination="YYV-02-abX" kind="showDetail" identifier="segueshowdetails" id="crf-TU-94x"/>
<segue destination="YYV-02-abX" kind="showDetail" identifier="segueshowtoshowdetails" action="showViewController:sender:" id="w2L-45-p7H"/>
<segue destination="YYV-02-abX" kind="show" identifier="segueshowdetailstoshow" action="showDetailViewController:sender:" id="7Z4-mJ-Pbh"/>

所以这可能是 Apple 方面的一个错误。

关于swift - 在 `kind` 和 "Show": why does the change not take effect when running the simulator? 之间更改 Storyboard segue "ShowDetail",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34291643/

相关文章:

ios - 为 UIWebkit 赋予 Value 并更改实例化 ViewController [Swift 4]

ios - UIImage 遍历像素非常低效?

ios - 从 iOS 9 开始,应用程序 :openURL:sourceApplication:annotation: is deprecated, 如何在 iOS 8 中使用新方法?

ios - Xcode 忽略 Storyboard警告

ios - UITableView 清空 iOS 9 beta 5 更新

ios - apple-app-site-association 文件格式错误

ios - 从 Objective C 代码调用 @escaping 完成处理程序时出现 EXC_BAD_ACCESS 错误

ios - Swift 3.0 在 MapView 上放置注释

ios - 查看应用重启前后的日志

ios - 在 iOS 9 中禁用网络时,HTTP GET 请求出现 fatal error