I use the same operation as if I clicked on a menu item in my left menu.
[self.anchorTopViewOffScreenTo:ECRight animations:nil onComplete:^{ CGRect frame = self.topViewController.view.frame; self.topViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"secondVC"]; self.topViewController.view.frame = frame; [self resetTopView]; }];
Just summarize it and you can call it everywhere. He does the animation himself. You can do it like @Alex, but if you don't need to do any custom animation, that's all you need.
NB. in my Im example using this in the initViewController (for which it is an ECSlidingViewController, so I send it to self ) to force the user to enter a specific viewController. If you need to change the view in any subViewControllers, you simply post to self.slidingViewController , as shown below:
[self.slidingViewController anchorTopViewOffScreenTo:ECRight animations:nil onComplete:^{ CGRect frame = self.slidingViewController.topViewController.view.frame; self.slidingViewController.topViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"secondVC"]; self.slidingViewController.topViewController.view.frame = frame; [self.slidingViewController resetTopView]; }];
source share