0

I present signup view controller modally from login view controller. My initial view controller is login view controller and when I present signup view controller modally, there is nothing wrong, but something wrong is occurring when I use ECSlidingViewController to reset top view on logout. I use following code to reset top view to login view controller on logout.

UIViewController *newTopViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"Login"];
[self.slidingViewController anchorTopViewOffScreenTo:ECRight animations:nil onComplete:^{
    self.slidingViewController.topViewController = newTopViewController;

    [self.slidingViewController resetTopView];

}];

When I present signup view modally after reseting top view with ECSlidingViewController, the presentingViewController property of signup view controller is set to another view controller, not login view controller.

I know that it is really hard to grasp the essence of the question, but If anyone needs any more detail so that they can answer this question, feel free to :)

CoderSpinoza
  • 2,145
  • 23
  • 28

1 Answers1

1

ECSlidingViewController does seem to mess with presentingViewController.

ECSlidingViewController has the property topViewController and you should be able to access the view controller you are expecting to be presentingViewController from there.

I was able to access the view controller you would expect to be presentingViewController as follows:

ECSlidingViewController *ec = (ECSlidingViewController*)self.presentingViewController;
if(ec) {
    UINavigationController *navController = (UINavigationController*)ec.topViewController;

    if(navController && navController.viewControllers.count) {

        UIViewController *top = navController.viewControllers[0];

        // now you'll need to cast top to your presenting view controller's class, eg:
        MyViewController *myVc = (MyViewController*)top;
        [myVc doSomething];
    }
}

You may not be using a navigation controller in your application, in which case it would be something like this (not tested):

ECSlidingViewController *ec = (ECSlidingViewController*)self.presentingViewController;
if(ec) {
    UIViewController *top = (UIViewController*)ec.topViewController;

    if(vc) {            
        // now you'll need to cast top to your presenting view controller's class, eg:
        MyViewController *myVc = (MyViewController*)top;
        [myVc doSomething];
    }
}
James Zaghini
  • 3,895
  • 4
  • 45
  • 61