ios - 使用容器 View Controller 和 Storyboard 构建滑出式菜单。我很困惑

标签 ios objective-c uiviewcontroller interface-builder uistoryboard

我对为 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)一起工作。在 Storyboard中实现这一点让我摸不着头脑。

最佳答案

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

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

相关文章:

ios - 点击 addChild viewController 不起作用

ios - 添加到 Storyboard的 UIBarButtonItem 在运行时不会出现

objective-c - 代表不工作

ios - 用渐变描边画一个圆

Objective-C 中的 C 代码(类/框架/库)

ios - 如何知道拖放结束时的最后一个 x 和 y 值?

ios - MFMailComposeViewController didFinishWithResult 未被调用

iphone - IOS - 将子 Controller / View 加载到 View 中

ios - 如何在 iOS 中同步两个异步委托(delegate)方法回调?

ios - 更改AppDelegate的 Root View Controller 导致UIViewControllerHierarchyInconsistency异常