I have a SplitViewController set up with a DetailViewController and a MasterViewController. The DetailViewController contains a map and I want to place a button on the map that collapses and expands the MasterViewController. Exactly like this in Apple's App Store app:
Clicking on the button then gives:
Any ideas on how I can achieve a similar effect? Note I don't want to close the top tool bar, just the MasterViewController. Thanks!
SOLUTION
Thanks to Pravin, my final solution in the IBAction is:
if (self.splitViewController.preferredDisplayMode == UISplitViewControllerDisplayModePrimaryHidden) {
self.splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModeAllVisible;
} else {
self.splitViewController.preferredDisplayMode = UISplitViewControllerDisplayModePrimaryHidden;
}
[UIView animateWithDuration:0.5 animations:^ {
[self.splitViewController.view layoutIfNeeded];
}];
hide master view
AppDelegate * appDelegateObj = (AppDelegate *)[UIApplication sharedApplication].delegate;
UISplitViewController * splitView = appDelegateObj.splitViewObj;
splitView.preferredDisplayMode = UISplitViewControllerDisplayModePrimaryHidden;
[UIView animateWithDuration:1.0 animations:^
{
[spv.view layoutIfNeeded];
}];
show master view
AppDelegate * appDelegateObj = (AppDelegate *)[UIApplication sharedApplication].delegate;
UISplitViewController * splitView = appDelegateObj.splitViewObj;
splitView.preferredDisplayMode = UISplitViewControllerDisplayModeAllVisible;
[UIView animateWithDuration:1.0 animations:^
{
[spv.view layoutIfNeeded];
}];
I hope it will useful for you!