I'd like to create a "slide-out-menu" for a portrait application on iOS 9 that allows pan gestures to switch between modes.
I would like it to switch between the modes "Hidden - The secondary view controller is displayed onscreen and the primary view controller is off screen" and "Overlay - The secondary view controller is onscreen and the primary view controller is layered on top of it."
According to Apple's documentation, I need to set preferredDisplayMode for the UISplitViewController. Can somebody tell me where to modify this property?
Hope you created a splitViewController and set that as the rootViewController in your AppDelegate
.
In viewDidLoad
of the splitViewController do
- (void)viewDidLoad
{[super viewDidLoad];
masterVC = [[MasterViewController alloc] init];
detailVC = [[DetailViewController alloc] init];
NSArray *vcArray = @[masterVC, detailVC];
self.viewControllers = vcArray;
self.preferredDisplayMode = UISplitViewControllerDisplayModeAutomatic;
self.presentsWithGesture = YES;
self.preferredPrimaryColumnWidthFraction = .10;
self.delegate = (id)self;}
It will work for sure I have tested it. MasterViewController is the primary viewController and DetailViewController is the secondaryviewController.
Note: In iOS 8 and later, you can use the UISplitViewController class on all iOS devices; in previous versions of iOS, the class is available only on iPad.