我正在尝试为弹出到 Root View Controller 创建自定义动画。我想创建一个动画,当前用户向下滑动并显示下面的新 View Controller ,以及我将添加的其他一些东西。我的大问题是我不知道如何将自定义动画添加到 popToRootViewController
。我已经为 presentViewController 创建了一个自定义动画,但不知道如何使用 popToRootViewController
做同样的事情。任何帮助都会很棒,顺便说一下,我不一定需要让 Controller 向下滑动的帮助,我只需要帮助让 Controller 显示任何动画。以下是我如何创建用于呈现 View Controller 的自定义动画:
FeedViewController *feed = [[FeedViewController alloc] init];
feed.transitioningDelegate = self;
feed.modalPresentationStyle = UIModalPresentationCustom;
[self presentViewController:feed animated:YES completion:nil];
最佳答案
您必须实现 UINavigationControllerDelegate 协议(protocol)方法:
- (id<UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController
animationControllerForOperation:(UINavigationControllerOperation)operation
fromViewController:(UIViewController *)fromVC
toViewController:(UIViewController *)toVC
此时您应该能够插入您的 transitioningDelegate(返回!)
如果您不想使用您的自定义 Controller ,您可以返回nil
。例如你可以使用
{
if(operation==UINavigationControllerOperationPop)
{
return MYTRANSITIONINGDELEGATE;
}
}
确保设置导航 Controller 的委托(delegate) ;)
关于ios - 向 popToRootViewController 添加自定义动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22774495/