ios - 在当前上下文 Storyboard上呈现 View Controller

标签 ios uiviewcontroller modalviewcontroller

一段时间以来,我一直在尝试解决这个问题,很多人提出了几种不同的方法来实现这个目标,但没有一个对我有用。

我试图在当前上下文中显示一个背景清晰的 View Controller 。但是,每次我执行 segue 时,下面的 View Controller 都会从 View 层次结构中删除。

这是呈现 View Controller 。 Presenting View Controller

这是模态呈现 View 时的当前状态。 Modal popup

当 segue 发生时,模态具有正确的透明效果,但是当 segue 完成时,背景变为黑色,表明 View Controller 已从层次结构中删除。

现在很多建议都集中在代码中设置模式,但是所有这些设置都可以在 Storyboard 中使用,我更喜欢将类似的东西留在那里。按照建议here我已经像这样设置了我的 View Controller ,但是我仍然有上述效果。

这是我的 Storyboard设置。

呈现 View Controller 设置 Presenting view controller settings

转场设置 Segue settings

模态视图 Controller 设置 Modal view controller settings

如有任何帮助,我们将不胜感激。

最佳答案

您可以使那些 View Controller 成为您想要在 here 上显示的 VC 的子级, 通过使一个 View Controller 成为另一个 View Controller 的 subview ,您可以将子 VC 的 View 作为 subview 添加到父 VC 的 View 中

然后您可以玩弄子 VC View 的透明度/颜色

这也很有帮助 tutorial

在当前 View Controller 之上呈现 View Controller 对您不起作用,您将添加其他 View Controller 作为当前 View Controller 的 subview ,然后将其 View 作为 subview 添加到当前 VC 的 View 中。然后,如果您清除子 VC View 的背景颜色,它将显示为透明,并在背景中显示之前的 VC View

编辑: 您可以使用演示 Controller 实现相同的效果 here

关于ios - 在当前上下文 Storyboard上呈现 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32115973/

相关文章:

iphone - UIModalTransitionStyle 水平移动

ios - 为按钮提供等宽约束时,自动布局设置不正确

c# - 如何使数字键盘出现在 Xamarin.iOS 中的 View Controller 条目上?

iOS 11 强制 UIViewController 到纵向模式不起作用

ios - 如何打破导航 Controller 链

Swift 模态表 : willPositionSheet does doesn't get called

iphone - iOS - 如何绘制一个带有数字/字符的圆圈?

ios - cordova 3.4.1-0.1.0 创建的 xcode 项目中的 www 文件夹不正确

ios - 确定您的应用程序之前是否在 iOS 中安装过

iOS 6 在模态呈现的 View Controller 中推送 View Controller