简体   繁体   English

如何在情节提要,自定义segue中实现弹出框控制器

[英]how to implement popover controller in storyboard, custom segue

This is mouli, I'm implementing a custom segue for pushing (with animation) from firstview to second view, its work fine. 这太简单了,我正在实现一个自定义segue,用于将(带有动画)从第一视图推送到第二视图,它的工作正常。 but iam not getting back from secondview to firstview with same animation. 但我无法使用相同的动画从secondview返回firstview。 Here the first screen appears with out animation. 这里出现的第一个屏幕没有动画。 please give some suggestion. 请提出一些建议。 Thanks in advance. 提前致谢。 following is my code for push from first to second. 以下是我从第一到第二的推送代码。

    UIViewController *sourceViewController = [UIApplication sharedApplication].delegate.window.rootViewController;
    NSLog(@"%@",sourceViewController);

    sourceViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
    UIViewController *destinationController = (UIViewController*)[self destinationViewController];
    NSLog(@"%@",destinationController);

    CATransition* transition = [CATransition animation];
    transition.duration = 0.6;
    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];

Do the dismiss in opposite way, since your are doing a custom animation other that the provided one, it doesn't remember the animation of presentation. 以相反的方式进行解散,因为您正在制作自定义动画,而不是提供的自定义动画,所以它不记得演示动画。 So while you are dismissing you need to apply the opposite custom animation too. 因此,在解雇时,您也需要应用相反的自定义动画。

I would suggest you to create a Category for animations and use them in the whole project easily.. 我建议您为动画创建一个类别,并在整个项目中轻松使用它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM