1

I have a split view controller with master view and detail view. Master View is fixed in the delegate function:

-(BOOL)splitViewController:(UISplitViewController *)svc shouldHideViewController:  
(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation
{
    return enableMaster;
}

When I click the button on detail view it navigates to a new screen. But on the new screen it still displays the master view.

Code for navigation:

 NextViewController *viewController = [...]; \\initialised here;
 [self.navigationController pushViewController:viewController animated:YES];

My question: 1. When I navigate to new screen from detail view controller, it should display next screen as a full screen. How to do that?
Note: I don't want to use "presentViewController" to display the next screen because of two reasons.
1. I want to come to previous screen using navigation stack
2. All the screens are also based on Tab bar controller, and if I use "presentViewController" then tab bar controller not longer visible for new screen.

After reading this post: How to hide & unhide Master View Controller in SplitView Controller

Solution: finally my problem has solved:

// In split delegate
-(void)hideMaster:(BOOL)hideState
{
   _masterIsHidden = hideState;
  [self.splitViewController.view setNeedsLayout];
   self.splitViewController.delegate = nil;
   self.splitViewController.delegate = self;
   [self.splitViewController willRotateToInterfaceOrientation:[UIApplication    
    sharedApplication].statusBarOrientation duration:0];
}

-(BOOL)splitViewController:(UISplitViewController *)svc shouldHideViewController: 
(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation
{
    return self.masterIsHidden;
}

//Call On button:
-(void) btn_click
{
     [self hideMaster: TRUE];
}
Community
  • 1
  • 1
  • This post solved my problem: http://stackoverflow.com/questions/8020323/how-to-hide-unhide-master-view-controller-in-splitview-controller?rq=1 – Simranjeet Kaur May 13 '14 at 15:39

1 Answers1

0

What you need to do is embed your UISplitViewController in a navigation controller itself. You'll want to hide this navigation controller's navigation bar so you don't end up with two. When you go to present your detail view, push it on the split view's navigation controller. It would look something like this:

NextViewController *viewController = [...]; \\initialised here;

UISplitViewController *splitVC = self.parentViewController.parentViewController;

[splitVC.navigationController pushViewController:viewController animated:YES];

Note that this is somewhat fragile; if the view controller hierarchy changes, the parent of the parent trick may break. It could be wise to keep a reference to your top level navigation controller on your app delegate (it should be the root view controller of your key window) and access it this way to future-proof your solution.

Patrick Goley
  • 5,397
  • 22
  • 42
  • This doesn't hide the master view on the next screen. It is still visible. I want to show my next screen as a full screen not the splitted one. – Simranjeet Kaur May 13 '14 at 14:34