问题描述
我正在使用Xcode 4.2,并且正在开发一个我希望菜单屏幕使用拆分视图的应用程序.确实,我所需的拆分视图控制器"是将某些菜单选项拆分为一个左窗格和一个右窗格.我希望能够为主视图和细节视图控制器设置自定义大小,但似乎没有任何效果.我尝试使用以下代码更新每个视图控制器的帧大小:
[self.view setFrame:CGRectMake(0, 0, 768, 502)];
在viewDidLoad函数中,但这似乎没有任何影响.
是否可以在不实例化AppDelegate.m文件中的视图控制器的情况下为拆分视图控制器的主视图控制器和详细视图控制器设置自定义大小?我希望能够在情节提要中编辑每个视图控制器,因为它们是带有许多按钮等的菜单屏幕.
在iOS 8+中,可以通过指定minimum/maximumPrimaryColumnWidth属性或preferredPrimaryColumnFraction来更改相对宽度.
以下答案对于iOS<仍然适用. 8:
您不能更改拆分视图控制器的大小.
"UISplitViewController类是管理两个信息窗格的容器视图控制器.第一个窗格的固定宽度为320点,高度与可见窗口的高度匹配.第二个窗格填充剩余的空间." >
I'm working in Xcode 4.2 and am developing an app where I want the menu screen to use a Split View. Really, all I need the Split View Controller for is to split some of the menu options into a left pane and right pane. I want to be able to set custom sizes for the master and detail view controllers, but nothing seems to be working for me. I've tried updating the frame sizes for each view controller with code like:
[self.view setFrame:CGRectMake(0, 0, 768, 502)];
in the viewDidLoad functions, but that doesn't seem to affect anything.
Is there a way to set custom sizes for the master and detail view controllers of a split view controller without instantiating the view controllers in say the AppDelegate.m file? I want to be able to edit each of the view controllers in the storyboard as they are menu screens with a lot of buttons and such.
Edit:In iOS 8+, the relative widths can be changed by specifying the minimum/maximumPrimaryColumnWidth properties or the preferredPrimaryColumnFraction.
The below answer is still true for iOS < 8:
You can't change the sizes for a split view controller.
"The UISplitViewController class is a container view controller that manages two panes of information. The first pane has a fixed width of 320 points and a height that matches the visible window height. The second pane fills the remaining space."
这篇关于在拆分视图控制器中调整主视图和详细视图控制器的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!