I'm using ECSliding and I have this problem!
In my project there are this files:
InitViewController (ECSlidingController)
FirstViewController (UIViewController)
SecondViewController (UIViewController)
LeftMenuViewController (UIViewController)
LeftMenuTwoViewController (UIViewController)
I use InitView to instatiate my FirstView as the topview.
Sliding right shows LeftMenuViewController, that has a button, if pressed change topview to SecondViewController. I would like to know if is it possible to use LeftMenuTwoViewController as the underLeftViewController of SecondView. Also I want a button in LeftMenuTwo that changes topView to FirstView.
I want a FirstView with underLeftViewController as LeftMenuViewController, and SecondView with underLeftViewController as LeftMenuTwoViewController. Each menu have a button that change the topView to the other one with different underLeftViewController.
I did this:
SecondViewController *second = [self.storyboard
instantiateViewControllerWithIdentifier:@"SecondTop"];
[self.slidingViewController anchorTopViewOffScreenTo:ECRight
animations:nil
onComplete:^{
self.slidingViewController.topViewController = second;
[self.slidingViewController resetTopViewWithAnimations:nil
onComplete:^{
LeftMenuTwoViewController *newUnderLeftVC = [self.storyboard
instantiateViewControllerWithIdentifier:@"LeftTwo"];
self.slidingViewController.underLeftViewController = newUnderLeftVC;
}];
}];
But when I push the button the topView starts the bouncing animation by sliding right but never comes back again and immediatly after the TopView goes off screen the underLeftViewController becomes blank. Anyone know why?
Download: My Project
Change the method to this:
-(IBAction)openSecond:(id)sender
{
SecondViewController *second = [self.storyboard instantiateViewControllerWithIdentifier:@"Second"];
ECSlidingViewController *slideController = self.slidingViewController;
[slideController anchorTopViewOffScreenTo:ECRight animations:nil onComplete:^{
slideController.topViewController = second;
[slideController resetTopViewWithAnimations:nil onComplete:^{
LeftMenuTwoViewController *newUnderLeftVC = [self.storyboard instantiateViewControllerWithIdentifier:@"LeftTwo"];
slideController.underLeftViewController = newUnderLeftVC;
}];
}];
}
The problem was that when the view removes itself as the top view controller, calling self.slidingViewController
no longer returns a valid instance (it returns nil).