Search code examples
objective-ciosipaduisplitviewcontrollersubclass

Subclass UISplitViewController and set custom width


I'm trying to subclass UISplitViewController to decrease the width of the master. I've looked at Matt Gemmell's MGSplitViewController - see Change the width of Master in UISplitViewController - but it looks like way more than I need. I just want to decrease the size of the master from 320 to 260 in a way that Apple will accept in the app store.

I'm new to subclassing anything other than a button, but this is what I'm trying so far, although it currently doesn't do anything. Either I'm way off the mark or I'm missing something simple. How can this be done?

Header file:

#import <UIKit/UIKit.h>

@interface MYSplitViewController : UISplitViewController

+ (CGFloat)masterColumnWidth;

@end

Implementation file:

#import "SRSplitViewController.h"

@interface SRSplitViewController ()

@end

@implementation SRSplitViewController

+ (CGFloat)masterColumnWidth {
  return 260;
}

@end

Solution

  • I ended up not going this route, and would recommend against trying to subclass UISplitViewController for others. It's not a flexible layout so unless you want exactly what it provides out of the box, you are going to run into time-consuming problems.

    If you want a side navigation bar similar to the Facebook app, I'd recommend using JASidePanels and placing whatever size and style view controller you want in the left panel.

    enter image description here