Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UINavigation controller with VCTransitionLibrary pop shows black screen when pushed without animation #30

Open
dulgan opened this issue Sep 1, 2014 · 1 comment

Comments

@dulgan
Copy link

dulgan commented Sep 1, 2014

Hi,

I followed your tutorials and use your VCTransitionLibrary in my app, here is my App structure :

  1. A NavigationController is the root of the application (using your tutorial code)
  2. MyRootViewController is the root view controller in the NavigationController
  3. MyPushedViewController is pushed or poped with animations by MyRootViewController

Everything is fine with animations, but a problem occur in the following configuration :

  1. MyRootViewController is on screen, (the only ViewController in the NavigationController stack)
  2. App goes to background
  3. App goes to foreground :
    3.1) applicationWillEnterForeground fires a notification to NSNotificationCenter defaultCenter
    3.2) MyRootViewController listen to this notification and execute the following code :
    // pop to root
    [self.navigationController popToRootViewControllerAnimated:NO];
    // instantiate new view controller
    MyPushedViewController *mpvc = [self.storyboard instantiateViewControllerWithIdentifier:@"MyPushedViewController"];
    // mpvc init code...
    // ...
    // push the new view controller
    [self.navigationController pushViewController:ncvc animated:NO];
  4. MyPushedViewController is displayed without any problem
  5. User swipe to trigger a pop, and MyRootViewController is black, not appearing in animation (but it's viewWillAppear is triggered).

I need to use animated:NO because I don't want the app to show anything else than MyPushedViewController when it's back to foreground.
The is no problem in any other configuration :
animated:YES display the animation fine
when MyPushedViewController was on screen, it's also working fine

Do you have any clue about this problem ?

Thanks for your work and your time !

@andriternovy
Copy link

Hi,

I had same issue, so I found workaround.

Replace - (void)animateTransition:(id)transitionContext method in the CEReversibleAnimationController for next code:

  • (void)animateTransition:(id)transitionContext
    {

    UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
    UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
    UIView *toView = toVC.view;
    UIView *fromView = fromVC.view;
    fromVC.view.backgroundColor = [UIColor colorWithPatternImage:[self imageWithView:fromVC.view]];

    [self animateTransition:transitionContext fromVC:fromVC toVC:toVC fromView:fromView toView:toView];
    }

  • (UIImage *)imageWithView:(UIView *)view
    {
    UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 0.0);
    [view.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage * img = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    return img;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants