Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/100.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
按下后退按钮时的自定义动画-iOS_Ios_Objective C_Uinavigationcontroller_Pushviewcontroller - Fatal编程技术网

按下后退按钮时的自定义动画-iOS

按下后退按钮时的自定义动画-iOS,ios,objective-c,uinavigationcontroller,pushviewcontroller,Ios,Objective C,Uinavigationcontroller,Pushviewcontroller,我试图在用户按下uiviewcontroller导航栏的默认后退按钮(而不是自定义按钮)时产生自定义效果。我试图在弹出视图之前将uiview向下移动到某个Y位置,然后让视图控制器消失 我尝试了两种方法: 方法1 - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [UIView animateWithDuration:0.2 animations:^{ self.c

我试图在用户按下uiviewcontroller导航栏的默认后退按钮(而不是自定义按钮)时产生自定义效果。我试图在弹出视图之前将uiview向下移动到某个Y位置,然后让视图控制器消失

我尝试了两种方法:

方法1

    - (void)viewWillDisappear:(BOOL)animated
{
  [super viewWillDisappear:animated];

  [UIView animateWithDuration:0.2 animations:^{
    self.cvCell.frame = self.selectedCellFrame;
  } completion:^(BOOL finished) {
  [UIView animateWithDuration:0.75
                     animations:^{

                         [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
                         [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.navigationController.view cache:NO];
                     } completion:^(BOOL finished) {

                         [self.navigationController popViewControllerAnimated:NO];
                     }];
    }];


}
方法2

-(void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{


if ([self.navigationController.viewControllers indexOfObject:self]==NSNotFound) {

    [UIView animateWithDuration:0.2 animations:^{
       self.cvCell.frame = self.selectedCellFrame;
    } completion:^(BOOL finished) {
       CATransition *transition = [CATransition animation];
       [transition setDuration:0.75];
       [transition setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
       [transition setType:kCATransitionReveal];
       [transition setSubtype:kCATransitionFromLeft];
       [transition setDelegate:self];
       [self.navigationController.view.layer addAnimation:transition forKey:nil];
     }];
  }
}
在这两种情况下,视图都会在UIView上的动画开始之前消失。
关于实现这一点有什么建议吗?

如果您在iOS应用程序中使用故事板,您可以尝试实现cusom segue动画。您可以覆盖方法
prepareforsgue:sender:
,以检查交易是否应该发生,并覆盖方法
perform:
以在屏幕上显示新的视图控制器。然后,您可以在其中子类化
UIStoryboardSegue
并启用自定义动画

我正试图从B弹出到viewcontroller A。我使用自定义segue动画(我确实使用故事板)从A降落到B上。我是否需要创建另一个自定义序列来弹出此视图控制器?是的,如果“返回”按钮自动返回,可能还需要重新配置“返回”按钮。查看后
prepareForSegue:sender:
仅在前进方向工作,要在后退方向移动,请使用
prepareForUnwind:sender:
此处的详细信息: