我正在构建一个带有固定顶部栏和底部一些固定按钮的应用程序。在我的 MainViewController 中间,我想要在一些表之间切换。我想要的方式:
- 点击底部的按钮
- 点击表格中的按钮
为了解决这个问题,我在 MainViewController 中放置了一个 ContainerView。通过单击底部的按钮之一来切换 InsideViewControllers 已经对我有用了。我用苹果解决了它Tutorial以编程方式。通过单击按钮,我更改了 ContainerView 的 childViewController。
当单击 InsideViewController 中的按钮时,我正在向我的 ParentViewController(容器)发送一条消息。我通过实现一个协议(protocol)并检查我的parentViewController 是否实现它来做到这一点。
现在我的问题是,这是否是在 ContainerView 内从 ViewController 单击到 ViewController 的最佳解决方案。或者是否有更好的方法来单击我的表上的按钮并获取下一个表?
我的想法也许是可能的:
Storyboard解决方案。我想在我的 Storyboard中连接 ViewController。这样我的第一个 View Controller 上就有一个按钮,并从这个 View Controller 到下一个 View Controller 。如果我像解释的那样这样做,新的 ViewController 不会填充容器。我的应用程序会弹出一个普通的 ViewController。这是这个想法的示例 View :
是否可以或者我是否继续向我的 parent 发送消息?
最佳答案
当然可以。您可以开始阅读Implementing a Container View Controller具体来说,“在 Interface Builder 中配置容器”部分。在添加容器 View 的初始阶段,您将自动看到一个新的 UIViewController 出现在那里。我想如果您想要执行转换,您将必须嵌入
新 View Controller 的导航 Controller 。
关于ios - Swift:在 ContainerView 中从 ViewController 单击到 ViewController 的 Storyboard解决方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44563496/