【发布时间】:2014-04-04 12:21:07
【问题描述】:
我有 ContainerViewController,它有两个 childviewcontrollers。所以我用 segues 调用我想显示的子视图控制器。我的问题是 childviewcontroller 的大小不同,所以我遇到容器视图大小的问题。我没有使用自动布局。
【问题讨论】:
标签: ios iphone objective-c uicontainerview
我有 ContainerViewController,它有两个 childviewcontrollers。所以我用 segues 调用我想显示的子视图控制器。我的问题是 childviewcontroller 的大小不同,所以我遇到容器视图大小的问题。我没有使用自动布局。
【问题讨论】:
标签: ios iphone objective-c uicontainerview
没有办法,只能:
尽可能多地利用界面构建器中的尺寸检查器。 在大多数情况下,我设法让子视图根据容器视图调整大小和移动。对于某些应用程序,我还为 iPhone 和 iPad 使用了单个 ViewController,而不使用 AutoLayout。
第一点无法完成的事情。使用代码调整大小和位置。在您的子控制器中实现一个方法来做到这一点。在初始化子控制器后调用它。
在 ContainerViewController 中:
childViewContainer.view.frame = self.view.frame;
或相反:
self.view.frame = childViewContainer.view.frame;
【讨论】: