1

I have implemented the ECSlidingViewController framework to my project. That works. I can switch between my Viewcontrollers with the left side menu.
But now I want to set the current view / top view by clicking a UIButton:

NSString *identifier = [NSString stringWithFormat:@"%@", @"newView"];

UIViewController *newTopViewController = [self.storyboard instantiateViewControllerWithIdentifier:identifier];

[self.slidingViewController anchorTopViewOffScreenTo:ECLeft animations:nil onComplete:^{
    CGRect frame = self.slidingViewController.topViewController.view.frame;
    self.slidingViewController.topViewController = newTopViewController;
    self.slidingViewController.topViewController.view.frame = frame;            
}];

When I click this button, the newView-ViewController is on top, but the left menu is also visible. I've tried everything like the following to hide the menu:

[self.slidingViewController anchorTopViewTo:ECRight];
...
self.slidingViewController.underRightWidthLayout = ECVariableRevealWidth;
...
[self.slidingViewController anchorTopViewTo:ECLeft];
...
[self.slidingViewController anchorTopViewOffScreenTo:ECLeft];
...
self.slidingViewController.underLeftWidthLayout = ECFullWidth;
...
[self.slidingViewController resetTopView];

How can I hide the left menu?

Sorry for my english mistakes, I'm from Germany.

David Rönnqvist
  • 56,267
  • 18
  • 167
  • 205
DerFuchs10
  • 135
  • 1
  • 2
  • 12

3 Answers3

0

Don't keep using self.slidingViewController during the whole process. It is evaluated each time so when you change the view controllers in the sliding controller you can break the link. So, cache the sliding controller reference and reuse it:

ECSlidingViewController *slidingViewController = self.slidingViewController;

[slidingViewController ...];
[slidingViewController ...];
Wain
  • 118,658
  • 15
  • 128
  • 151
0

Calling resetTopView at the end of the onComplete block should hide the menu.

Michael Enriquez
  • 2,520
  • 21
  • 13
0

Show/Hide SlideViewController

[viewController.slidingViewController anchorTopViewToRightAnimated:YES];
    if ([viewController.slidingViewController currentTopViewPosition] == ECSlidingViewControllerTopViewPositionAnchoredRight) {
        [viewController.slidingViewController resetTopViewAnimated:YES];
    }
Kirit Vaghela
  • 12,572
  • 4
  • 76
  • 80