OGeek|极客世界-中国程序员成长平台

标题: ios - 使用容器 View Controller 和 Storyboard 构建滑出式菜单。我很困惑 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 17:09
标题: ios - 使用容器 View Controller 和 Storyboard 构建滑出式菜单。我很困惑

我有兴趣为 View Controller 构建一个滑出侧边栏,并且我已经阅读了大量关于如何实现它的文章。 This tutorial ,以及几乎所有其他人都在创建 subview Controller ,这似乎是一个很好的方法。但是,它总是在示例代码中完成。

This post讨论了如何在 Storyboard 中创建容器 View Controller ,但它让我感到困惑容器 View 在 Storyboard 中究竟是如何工作的,而且似乎在线解释的方式很少。

最后,this post讨论了如何使用容器 View Controller 和 Storyboard 实现滑出菜单。听起来很完美吧?好吧,在阅读它时,我很困惑作者似乎如何使用多个容器 View 。我认为应该有一个包含所有 subview Controller 的一个。在那篇文章中正确实现了吗?

基本上,我很想解释一下如何通过 Storyboard 使用容器 View Controller 来实现多个 View Controller 。我从第一个教程中了解到,您拥有包含所有内容的 View Controller ,然后将 View Controller 添加到该容器,然后它们都通过委托(delegate)一起工作。在 Storyboards 中实现这一点让我摸不着头脑。



Best Answer-推荐答案


添加容器基本上是将 subview Controller 及其 View 添加到主 Controller 。我认为您在这里不清楚两件事。首先,每个容器只能链接到 1 个 Controller / View 对。所以,如果你想拥有多个子 Controller ,你必须拥有多个容器。其次,父子 Controller 之间的通信由“embed segues”处理,而不是委托(delegate)。

关于ios - 使用容器 View Controller 和 Storyboard 构建滑出式菜单。我很困惑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20533700/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4