Echilon
Echilon

Reputation: 10264

Popping a ViewController inside SplitViewController

I have a UISplitViewController containing a UINavigationController on the left hand side and another custom VC on the right. The left is like a filtering system, so views will be pushed/popped onto it. The right displays the actual details.

I've subclassed UISplitViewController and UINavigationController.

I have these set up in IB, with a third VC as the rootViewController of Nav Controller (contains a list of menu options). In my subclassed UISplitViewController's viewDidLoad, I do

    splitNavVc = [self.viewControllers objectAtIndex:0]; // get reference to nav controller for navigation
    [self.splitNavVc pushViewController:recipeTable animated:true]; // push the first level view on by default. As though the user had selected an item from the menu controller at the nav controller's root.

This works fine, bu when I come to pop the top VC to show the menu at the root again:

[self.splitNavVc popViewControllerAnimated:true];

The transition isn't a left->right in just the left hand pane, but rather a top->bottom transition of the entire splitViewController. The weird thing is, though the full screen transitions, the right side of my splitViewController doesn't actually change.

It's as though something's not connected somewhere.

Upvotes: 2

Views: 870

Answers (1)

Echilon
Echilon

Reputation: 10264

Eventually solved by using popToRootViewControllerAnimated instead.

I connected the navigation controller to it's root controller, then created Segues in my storyboard for the two 'drill down' views. The I used performSegueWithIdentifier to push the ViewController and to pop it off again I used

[self.menuVc.navigationController popToRootViewControllerAnimated:true]; // menuVc is the rootViewController in this case

Upvotes: 1

Related Questions