ios segues 之间有什么区别:“show”、“show detail”、“present modal”、“present as popover”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26287247/
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 03:06:44  来源:igfitidea点击:

What are the differences between segues: "show", "show detail", "present modally", "present as popover"?

iosxcodexcode6segue

提问by Red

What do the different segues do in Xcode 6?

Xcode 6 中不同的 segue 有什么作用?

回答by Rajesh Loganathan

1. Show- Pushes the destination view controller onto the navigation stack, moving the source view controller out of the way (destination slides overtop from right to left), providing a back button to navigate back to the source - on all devices.

Example: Navigating inboxes/folders in Mail.

2. Show Detail- Replaces the detail/secondary view controller when in a UISplitViewController with no ability to navigate back to the previous view controller.

Example: In Mail on iPad in landscape, tapping an email in the sidebar replaces the view controller on the right to show the new email.

3. Present Modally- Presents a view controller in various different ways as defined by the Presentation option, covering up 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, but on iPad it's common to present it in a centered box format overtop that darkens the underlying view controller.

Example: Tapping the + button in Calendar on iPhone.

4. Popover Presentation- When run on iPad, the destination appears in a small popover, and tapping anywhere outside of this popover will dismiss it. On iPhone, popovers are supported as well but by default if it performs a Popover Presentation segue, it will present the destination view controller modally over the full screen.

Example: Tapping the + button in Calendar on iPad (or iPhone, realizing it is converted to a full screen presentation as opposed to an actual popover).

5. Custom- You may implement your own custom segue and have complete control over its appearance and transition.

1. 显示- 将目标视图控制器推送到导航堆栈上,将源视图控制器移开(目标从右向左滑过顶部),提供后退按钮以导航回源 - 在所有设备上。

示例:在邮件中导航收件箱/文件夹。

2. 显示细节- 在 UISplitViewController 中替换细节/辅助视图控制器,无法导航回前一个视图控制器。

示例:在 iPad 上的 Mail 横向模式中,点击侧栏中的电子邮件会替换右侧的视图控制器以显示新电子邮件。

3. Present Modally- 以Presentation选项定义的各种不同方式呈现视图控制器,覆盖之前的视图控制器 - 最常用于呈现从底部向上动画并覆盖iPhone上的整个屏幕的视图控制器,但是在 iPad 上,通常以居中框格式呈现它,使底层视图控制器变暗。

示例:点击 iPhone 日历中的 + 按钮。

4. Popover Presentation- 在 iPad 上运行时,目的地会出现在一个小的弹出窗口中,点击该弹出窗口之外的任何地方都会将其关闭。在 iPhone 上,也支持弹出框,但默认情况下,如果它执行弹出框演示转场,它将在全屏上模态地显示目标视图控制器。

示例:点击 iPad 上日历中的 + 按钮(或 iPhone,意识到它被转换为全屏演示而不是实际的弹出窗口)。

5. 自定义- 您可以实现自己的自定义转场并完全控制其外观和过渡。