Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resize master and detail view controllers in a split view controller?

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.

like image 312
generaltsow Avatar asked Apr 16 '12 02:04

generaltsow


2 Answers

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.

See here: http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/Introduction/Introduction.html

"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."

like image 170
Adam Shiemke Avatar answered Nov 23 '22 09:11

Adam Shiemke


Use MGSplitViewController. It offers similar API to UIViewController, but offering additional features, such as split position, which is what you need.

like image 25
Léo Natan Avatar answered Nov 23 '22 10:11

Léo Natan