Skip to content
This repository was archived by the owner on Jan 14, 2018. It is now read-only.

Explicitly declare the top, left, right controller ivars as protected#282

Merged
enriquez merged 1 commit intoECSlidingViewController:masterfrom
jeffbailey:master
Feb 5, 2014
Merged

Explicitly declare the top, left, right controller ivars as protected#282
enriquez merged 1 commit intoECSlidingViewController:masterfrom
jeffbailey:master

Conversation

@jeffbailey
Copy link
Copy Markdown

Explicitly declare the topViewController, underLeftViewController, and underRightViewController ivars as protected so a subclass of ECSlidingViewController has access.

This change was needed in order to provide a custom transition when changing the topViewController. We need to provide an alternate way (i.e. shortcut) for our app to navigate from one top view controller to another one. In particular, the current top view controller has a button that when tapped will transition directly to a new top controller. If we just called the setTopViewController method then we would not have the ability to provide our own animation (e.g. cross dissolve) from the current top controller to the new one. With this change we were able to subclass ECSlidingViewController and add the following method:

- (void)transitionToViewController:(UIViewController *)toViewController
{
   UIViewController *oldTopViewController = _topViewController;

   [self addChildViewController:toViewController];
   [toViewController didMoveToParentViewController:self];

   toViewController.view.frame = self.topViewController.view.frame;

   if ([self isViewLoaded]) {
       [toViewController beginAppearanceTransition:YES animated:YES];
       [self.view addSubview:toViewController.view];
       [toViewController endAppearanceTransition];
   }

   [UIView transitionFromView:oldTopViewController.view
toView:toViewController.view duration:0.5
options:UIViewAnimationOptionTransitionCrossDissolve completion:^ (BOOL
finished) {
       [oldTopViewController.view removeFromSuperview];
       [oldTopViewController willMoveToParentViewController:nil];
       [oldTopViewController beginAppearanceTransition:NO animated:YES];
       [oldTopViewController removeFromParentViewController];
       [oldTopViewController endAppearanceTransition];
       _topViewController = toViewController;
   }];
}

…d underRightViewController ivars as protected so a subclass of ECSlidingViewController has access.

This change was needed in order to provide a custom transition when changing the topViewController.
enriquez added a commit that referenced this pull request Feb 5, 2014
Explicitly declare the top, left, right controller ivars as protected
@enriquez enriquez merged commit 4c22ecc into ECSlidingViewController:master Feb 5, 2014
@enriquez
Copy link
Copy Markdown
Member

enriquez commented Feb 5, 2014

Thanks @jeffbailey

@jeffbailey
Copy link
Copy Markdown
Author

Thanks Mike! Appreciate it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants