UINavigationController:在相反的方向popup视图控制器

我试图调用[[self navigationController] popViewControllerAnimated:YES]但使animation从右到左而不是从左到右。 任何简单的方法来做到这一点? 我想返回到以前的视图。 任何帮助表示赞赏。 谢谢!

这是可能的,看看我用了一段时间后面的代码,并尝试使它为自己工作。 Yu只需要改变setAnimationTransition

 [UIView beginAnimations:nil context:NULL]; [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; [UIView setAnimationDuration:0.75]; [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO]; [UIView commitAnimations]; [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDelay:0.375]; [self.navigationController popViewControllerAnimated:NO]; [UIView commitAnimations]; 

有几种不同的默认animation可供使用,苹果网站说这种animation是可能的:

 typedef enum { UIViewAnimationTransitionNone, UIViewAnimationTransitionFlipFromLeft, UIViewAnimationTransitionFlipFromRight, UIViewAnimationTransitionCurlUp, UIViewAnimationTransitionCurlDown, } UIViewAnimationTransition; 

所以在你的情况下,你会想要使用以下内容:

  [UIView beginAnimations:nil context:nil]; [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut]; [UIView setAnimationDuration:0.75]; [self.navigationController popViewControllerAnimated:NO]; [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO]; [UIView commitAnimations]; 

这就是如何在相反方向popup视图控制器。 它为我工作100%

 CATransition *transition = [CATransition animation]; transition.duration = 0.45; transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]; transition.type = kCATransitionFromRight; [transition setType:kCATransitionPush]; transition.subtype = kCATransitionFromRight; [self.navigationController.view.layer addAnimation:transition forKey:nil]; [self.navigationController popViewControllerAnimated:NO];