Little Background :-
I have two storyboards in my project (one with autolayout and one without autolayout). 'Main' storyboard contains ECSlidingViewController where I set topviewcontroller as mentioned on the ECSliding github page like below:-
My Code:-
-(void)GoToNewStoryBoard
{
UIStoryboard *storyboardWithAutolayout = [UIStoryboard storyboardWithName:@"AutolayoutBoard" bundle:nil];
self.slidingViewController.topViewController = [storyboardWithAutolayout instantiateViewControllerWithIdentifier:@"ViewControllerinNewStoryBoard"];
}
-(void)someMethodInNewViewController
{
ECSlidingViewController *sliding_viewController = (ECSlidingViewController*)[self.navigationController visibleViewController];
if([sliding_viewController isKindOfClass:[ECSlidingViewController class]])
{
MenuViewController *menu = (MenuViewController *)sliding_viewController.underLeftViewController;
NSString *windowType = [[NSUserDefaults standardUserDefaults] valueForKeyPath:@"menuWindowType"];
if([windowType isEqualToString:@"Push_PaymentPage"])
{
[menu pushToViewController];
}
}
}
-(void)pushToViewControllerInNewStoryBoard
{
self.slidingViewController.topViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"NewVCNav"];
[self.slidingViewController resetTopViewAnimated:YES];
}
Problem:-
How do I get the instance of ECSlidingViewController in View controller class in new storyboard as [self.navigationController visibleViewController] gives me instance of UIViewController class instead of ECSlidingViewController.
You need to create the object into
AppDelegate.mfile.Create one more method into the
AppDelegate.mfile.Now you can access those method and object of
ECSlidingViewController.Import AppDelegate file into your controller.
Then Access appDelegate Object. AppDelegate appDel = (AppDelegate*)[[UIApplication sharedApplication] delegate];
Then Access appDelegate method.