ContainerView具有多个嵌入segues [英] ContainerView with multiple embed segues

查看:142
本文介绍了ContainerView具有多个嵌入segues的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法让一个包含多个嵌入段的ContainerView?目的是让ContainerView根据按下的按钮保持几个不同的ViewControllers;一次只能看到一个。我想使用嵌入segues,以便在Interface Builder中,故事板会自动显示与ContainerView相同的大小。

Is there a way to have a single ContainerView with multiple embed segues? The aim is for a ContainerView to hold a few different ViewControllers depending on what buttons have been pressed; only one is going to be visible at a time. I want to use embed segues so that in Interface Builder the storyboards are automatically shown at the same size as the ContainerView.

我意识到我可以手动调整其他ViewControllers的大小InterfaceBuilder,但我想要嵌入segue提供的自动调整大小。如果可以采用另一种方式,那也没关系。没有在viewDidLoad上加载视图很好 - 如前所述,显示的ViewController可以根据按下的按钮而改变。

I realise that I can manually resize the other ViewControllers in InterfaceBuilder, but I want the automatic sizing provided by the embed segue. If another way of doing that is available, that would be fine too. Not having the views load on viewDidLoad is fine - as mentioned earlier, the shown ViewController can change depending on the buttons pressed.

推荐答案

不,没有办法将多个嵌入segue放到一个容器视图中。在IB中进行所有设置的一种方法是使嵌入式控制器成为UITabBarController(隐藏标签栏)。然后,您可以根据需要在选项卡中包含任意数量的控制器,并使用UITabBarController的selectedIndex属性在代码中切换到它们。

No, there is no way to have multiple embed segues to one container view. One way to do all the setup in IB, would be to make the embedded controller a UITabBarController (with the tab bar hidden). You can then have as many controllers in the tabs as you want, and switch to them in code using the selectedIndex property of UITabBarController.

这篇关于ContainerView具有多个嵌入segues的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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