Storyboard中的Modal和Push segue有什么区别? [英] What is the difference between Modal and Push segue in Storyboards?

查看:87
本文介绍了Storyboard中的Modal和Push segue有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以向我解释一下 modal push segue之间的确切区别?

Can someone explain to me what is the exact difference between modal and push segue?

我知道当我们使用 push 时,segue会被添加到堆栈中,所以当我们继续使用推送时它会占用内存吗?

I know that when we use push the segue gets added to a stack, so when we keep using push it keeps occupying memory?

有人可以告诉我这两个是如何实现的吗?

Can someone please show me how these two are implemented?

模态可以通过 ctrl-click 创建segue并拖动到目的地但是当我使用 push 执行此操作时,我的应用程序崩溃了。

Modal segues can be created by simply ctrl-click and dragging to destination but when I do that with the push my app crashes.

我正从一个按钮推送到 UINavigationController ,它有一个 UIViewController

I am pushing from a button to a UINavigationController that has a UIViewController.

推荐答案

推送Segue 正在向导航堆栈添加另一个VC。这假设发起推送的VC是添加到堆栈的VC所属的同一导航控制器的一部分。内存管理不是导航控制器和深层堆栈的问题。只要您正在处理可能从一个VC传递到另一个VC的对象,运行时就会处理导航堆栈。查看图片以获取可视指示:

A push Segue is adding another VC to the navigation stack. This assumes that VC that originates the push is part of the same navigation controller that the VC that is being added to the stack belongs to. Memory management is not an issue with navigation controllers and a deep stack. As long as you are taking care of objects you might be passing from one VC to another, the runtime will take care of the navigation stack. See the image for a visual indication:

模态Segue 只是一个VC以模态方式呈现另一个VC。 VC不必是导航控制器的一部分,并且以模态方式呈现的VC通常被认为是呈现(父)VC的子。模态呈现的VC通常没有任何导航栏或标签栏。呈现VC还负责解雇它创建和呈现的模态VC。

A modal Segue is just one VC presenting another VC modally. The VCs don't have to be part of a navigation controller and the VC being presented modally is generally considered to be a "child" of the presenting (parent) VC. The modally presented VC is usually sans any navigation bars or tab bars. The presenting VC is also responsible for dismissing the modal VC it created and presented.

希望这有帮助。

这篇关于Storyboard中的Modal和Push segue有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆