ECSlidingViewController with Push and Unwind Segue

485 Views Asked by At

I am using ECSlidingViewController with storyboards. ECSlidingVC is my root (starting) controller. My left menu is a TableView with static cells, and my TopViewController is a navigation controller. I want to have a single NavigationController for all my app.

From my left menu i cant use push or unwind segues, i understand that part though. i can only use ECSlidingSegue which changes topviewController of ECSlidingVC and which destroys my navigation controller and it's stack.

i want to be able to go back from a menu item VC to previous VC in my main nav controller. lets say basically i want ECSlidingVC to not change topViewController but push destination viewController to my source.topViewController.navigationController.

Also i need to use unwind segues with my menu items. i need to go back to a VC in my main nav controller.

i inspected ECSlidingSegue source code and all it does is to replace topViewController.

is there a built in method (or segue) in ECSlidingViewController for pushing (or unwinding) VC into source.topViewController.navController or do i need to implement a custom segue myself?

2

There are 2 best solutions below

0
On BEST ANSWER

I think the best way to go is for you to implement a custom segue yourself. Something like ECSlidingNavigationSegue, which would look for your topViewController, then check whether it's a UINavigationController and then push the destinationController to it.

It's basically the same perform method as the ECSlidingSegue, but with this feature of pushing a controller to the topViewController instead of replacing it.

Good luck!

0
On

In case someone haven't found answer, I did it in this way.

1- #import "UIViewController+ECSlidingViewController.h" to your menuViewController 2- Set stroboardID of your destinationViewController to "someID" 3- When triggering some action, in backend, use this code:

    if(self.slidingViewController.currentTopViewPosition == ECSlidingViewControllerTopViewPositionCentered){
        [self.slidingViewController anchorTopViewToRightAnimated:YES];
    }
    else{
        self.slidingViewController.topViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"someID"];
        [self.slidingViewController resetTopViewAnimated:YES];
    }