Resize primary and detailed view controllers in a split view controller?

I work in Xcode 4.2 and develop an application where I want the menu screen to use Split View. In fact, all I need is a Split View Controller to separate sections of some menu options into the left panel and the right panel. I want to be able to set my own sizes for the controllers of the main and detailed view, but nothing works for me. I tried updating frame sizes for each view controller using code, for example:

[self.view setFrame:CGRectMake(0, 0, 768, 502)];

in the viewDidLoad functions, but that doesn't affect anything.

Is there a way to set custom sizes for master and detailed view controllers of a split view controller without instantiating view controllers, for example, in the AppDelegate.m file? I want to be able to edit each of the view controllers in a storyboard, as they are menu screens with many buttons, etc.

+5
source share
3 answers

Edit: In iOS 8+, relative widths can be changed by specifying the minimum / maximum properties of the PrimaryColumnWidth or the preferred PrimaryColumnFraction.

The following answer is still valid for iOS <8:


You cannot resize for a split view controller.

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

" UISplitViewController - , . 320 , . .

+10

MGSplitViewController. API UIViewController, , , .

+4
- (CGFloat)splitView:(NSSplitView *)splitView constrainMinCoordinate:(CGFloat)proposedMinimumPosition ofSubviewAt:(NSInteger)dividerIndex;
{

    return proposedMinimumPosition + 238;
}

- (CGFloat)splitView:(NSSplitView *)splitView constrainMaxCoordinate:(CGFloat)proposedMaximumPosition ofSubviewAt:(NSInteger)dividerIndex;
{
    return proposedMaximumPosition - 200;
}

before the above delegate method adds [splitView addDelegate:self];

-1
source

All Articles