ios 所有选择 Segue 之间有什么区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25966215/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 02:41:15  来源:igfitidea点击:

What's the difference between all the Selection Segues?

iosios8xcode6segue

提问by User

  • Show
  • Show Detail
  • Present Modally
  • Popover presentation
  • Custom
  • 展示
  • 查看详细
  • 模态呈现
  • 弹出展示
  • 风俗

enter image description here

在此处输入图片说明

What is the difference between them? I couldn't find any documentation on it. There used to be some which I found in a Google search, but it's now gone: https://developer.apple.com/library/ios/recipes/xcode_help-interface_builder/articles-storyboard/StoryboardSegue.html

它们之间有什么区别?我找不到任何关于它的文档。曾经有一些我在谷歌搜索中找到的,但现在不见了:https: //developer.apple.com/library/ios/recipes/xcode_help-interface_builder/articles-storyboard/StoryboardSegue.html

回答by Jordan H

Here is a quick summary of the segues and an example for each type.

这是 segue 的快速摘要和每种类型的示例。

Show- Pushes the destination view controller onto the navigation stack, sliding overtop from right to left, providing a back button to return to the source - or if not embedded in a navigation controller it will be presented modally
Example:Navigating inboxes/folders in Mail

显示- 将目标视图控制器推送到导航堆栈上,从右向左滑动到顶部,提供返回按钮以返回源 - 或者如果未嵌入到导航控制器中,它将以模态呈现
示例:在邮件中导航收件箱/文件夹

Show Detail- For use in a split view controller, replaces the detail/secondary view controller when in an expanded 2 column interface, otherwise if collapsed to 1 column it will push in a navigation controller
Example:In Messages, tapping a conversation will show the conversation details - replacing the view controller on the right when in a two column layout, or push the conversation when in a single column layout

显示详细信息- 用于拆分视图控制器,在展开的 2 列界面中替换详细信息/辅助视图控制器,否则如果折叠到 1 列,它将推入导航控制器
示例:在消息中,点击对话将显示对话详细信息 - 在两列布局中替换右侧的视图控制器,或在单列布局中推送对话

Present Modally- Presents a view controller in various animated fashions as defined by the Presentation option, covering the previous view controller - most commonly used to present a view controller that animates up from the bottom and covers the entire screen on iPhone, or on iPad it's common to present it as a centered box that darkens the presenting view controller
Example:Selecting Touch ID & Passcode in Settings

Present Modally- 以 Presentation 选项定义的各种动画方式呈现视图控制器,覆盖之前的视图控制器 - 最常用于呈现从底部向上动画并覆盖 iPhone 或 iPad 上的整个屏幕的视图控制器通常将其呈现为一个居中的框,使呈现的视图控制器变暗
示例:在设置中选择 Touch ID 和密码

Popover Presentation- When run on iPad, the destination appears in a popover, and tapping anywhere outside of this popover will dismiss it, or on iPhone popovers are supported as well but by default it will present the destination modally over the full screen
Example:Tapping the + button in Calendar

Popover Presentation- 在 iPad 上运行时,目标出现在一个弹出窗口中,点击此弹出窗口之外的任何地方都会将其关闭,或者在 iPhone 上也支持弹出窗口,但默认情况下它将在全屏上以模态方式呈现目标
示例:点击日历中的 + 按钮

Custom- You may implement your own custom segue and have control over its behavior

自定义- 您可以实现自己的自定义转场并控制其行为

The deprecated segues are essentially the non-adaptive equivalents of those described above. These segue types were deprecated in iOS 8: Push, Modal, Popover, Replace.

不推荐使用的 segue 本质上是上述那些的非自适应等价物。这些 segue 类型在 iOS 8 中已被弃用:Push、Modal、Popover、Replace。

For more info, you may read over the Using Segues documentationwhich also explains the types of segues and how to use them in a Storyboard. Also check out Session 216 Building Adaptive Apps with UIKitfrom WWDC 2014. They talked about how you can build adaptive apps using these new Adaptive Segues, and they built a demo project that utilizes these segues.

有关更多信息,您可以阅读Using Segues 文档,该文档还解释了 segue 的类型以及如何在 Storyboard 中使用它们。另请查看WWDC 2014 的Session 216 Building Adaptive Apps with UIKit。他们讨论了如何使用这些新的 Adaptive Segues 构建自适应应用程序,并且他们构建了一个利用这些 segues 的演示项目。

回答by Ambroise Collon

For clarity, I'd like to illustrate @Joey's answer above with these gifs :

为了清楚起见,我想用这些 gif 来说明上面@Joey 的回答:

Show

展示

enter image description here

在此处输入图片说明

Show Detail

查看详细

enter image description here

在此处输入图片说明

Present Modally

模态呈现

enter image description here

在此处输入图片说明

Present As Popover

呈现为弹出框

enter image description here

在此处输入图片说明

回答by endavid

The document has moved here it seems: https://help.apple.com/xcode/mac/8.0/#/dev564169bb1

该文件似乎已移至此处:https: //help.apple.com/xcode/mac/8.0/#/dev564169bb1

Can't copy the icons here, but here are the descriptions:

此处无法复制图标,但这里是说明:

  • Show: Present the content in the detail or master area depending on the content of the screen.

    If the app is displaying a master and detail view, the content is pushed onto the detail area. If the app is only displaying the master or the detail, the content is pushed on top of the current view controller stack.

  • Show Detail: Present the content in the detail area.

    If the app is displaying a master and detail view, the new content replaces the current detail. If the app is only displaying the master or the detail, the content replaces the top of the current view controller stack.

  • Present Modally: Present the content modally.

  • Present as Popover: Present the content as a popover anchored to an existing view.

  • Custom: Create your own behaviors by using a custom segue.

  • 显示:根据屏幕内容在详细信息或主区域显示内容。

    如果应用程序正在显示主视图和详细信息视图,则内容会被推送到详细信息区域。如果应用程序只显示 master 或 detail,内容将被推送到当前视图控制器堆栈的顶部。

  • 显示详细信息:在详细信息区域显示内容。

    如果应用程序正在显示主视图和详细信息视图,则新内容将替换当前详细信息。如果应用程序只显示 master 或 detail,则内容将替换当前视图控制器堆栈的顶部。

  • 以模态呈现:以模态呈现内容。

  • Present as Popover:将内容呈现为锚定到现有视图的弹出窗口。

  • 自定义:使用自定义转场创建您自己的行为。

回答by jreft56

For those who prefer a bit more practical learning, select the segue in dock, open the attribute inspector and switch between different kinds of segues (dropdown "Kind"). This will reveal options specific for each of them: for example you can see that "present modally" allows you to choose a transition type etc.

对于那些更喜欢实践学习的人,请在 Dock 中选择 segue,打开属性检查器并在不同种类的 segue 之间切换(下拉“种类”)。这将显示每个选项的特定选项:例如,您可以看到“模态呈现”允许您选择过渡类型等。