Search code examples
iosobjective-cuistoryboardseguecatransition

Custom Segue Animation showing black screen


I am struck with a new problem, on presenting the destinationViewController using custom segue, during transition the source ViewController is changed to black screen, i need the screen to be as it is (my design).

UIViewController *sourceViewController = (UIViewController*)[self sourceViewController];
UIViewController *destinationController = (UIViewController*)[self destinationViewController][screenshot][1]

CATransition* transition = [CATransition animation];
transition.duration = 0.1;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush; //kCATransitionMoveIn; //, kCATransitionPush, kCATransitionReveal, kCATransitionFade
transition.subtype = kCATransitionFromRight; //kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom


[destinationController.view.layer addAnimation:transition forKey:kCATransition];
[sourceViewController presentViewController:destinationController animated:NO completion:nil];

Solution

  • I think you need to keep the context, try this:

        UIViewController *rootViewController = [UIApplication sharedApplication].delegate.window.rootViewController;
        rootViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
        UIViewController *destinationController = (UIViewController*)[self destinationViewController]
        [sourceViewController presentViewController:destinationController animated:NO completion:nil];