Change the width of Master in UISplitViewController
If you subclass UISplitViewController, you can implement -viewDidLayoutSubviews
and adjust the width there. This is clean, no hacks or private APIs, and works even with rotation.
- (void)viewDidLayoutSubviews{ const CGFloat kMasterViewWidth = 240.0; UIViewController *masterViewController = [self.viewControllers objectAtIndex:0]; UIViewController *detailViewController = [self.viewControllers objectAtIndex:1]; if (detailViewController.view.frame.origin.x > 0.0) { // Adjust the width of the master view CGRect masterViewFrame = masterViewController.view.frame; CGFloat deltaX = masterViewFrame.size.width - kMasterViewWidth; masterViewFrame.size.width -= deltaX; masterViewController.view.frame = masterViewFrame; // Adjust the width of the detail view CGRect detailViewFrame = detailViewController.view.frame; detailViewFrame.origin.x -= deltaX; detailViewFrame.size.width += deltaX; detailViewController.view.frame = detailViewFrame; [masterViewController.view setNeedsLayout]; [detailViewController.view setNeedsLayout]; }}
In IOS 8.0 you can easily do this by doing the following:
1. In your MasterSplitViewController.h add
@property(nonatomic, assign) CGFloat maximumPrimaryColumnWidth NS_AVAILABLE_IOS(8_0);
2. In your MasterSplitViewController.m viewDidLoad method add
self.maximumPrimaryColumnWidth = 100; self.splitViewController.maximumPrimaryColumnWidth = self.maximumPrimaryColumnWidth;
This is a really good, simple and easy feature of IOS 8.
this code is work for me
[splitViewController setValue:[NSNumber numberWithFloat:200.0] forKey:@"_masterColumnWidth"];