iphone开发人员:如何控制视图转换动画?

iphone开发人员:如何控制视图转换动画?,iphone,ios,Iphone,Ios,我使用这样的代码来呈现一个新的视图,我不知道它是好是坏。当前默认动画是从下往上显示视图,但我希望它从右向左(飞入)设置动画,是否可以更改默认动画类型以及如何更改?谢谢 [self presentModalViewController:navController animated:animated]; 可以按如下方式禁用向上滑动动画: [self presentModalViewController:navController animated:NO]; 然后,您可以提供自己的动画代码: na

我使用这样的代码来呈现一个新的视图,我不知道它是好是坏。当前默认动画是从下往上显示视图,但我希望它从右向左(飞入)设置动画,是否可以更改默认动画类型以及如何更改?谢谢

[self presentModalViewController:navController animated:animated];

可以按如下方式禁用向上滑动动画:

[self presentModalViewController:navController animated:NO];
然后,您可以提供自己的动画代码:

navController.view.frame = CGRectMake(320, 0, navController.view.frame.size.width, navController.view.frame.size.height);

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
navController.view.frame = CGRectMake(0, 0, navController.view.frame.size.width, navController.view.frame.size.height);
[UIView commitAnimations];
本例为您提供了从右侧“飞入”的平滑速度曲线

另一种方法是使用navigationcontroller的内置右滑入功能:

[self.navigationController pushViewController:navController animated:YES];

在本例中,您的top viewcontroller需要是UINavigationController,而它的rootcontroller需要是您的viewcontroller。然后,您可以推送其他ViewController。

我已经完成了这项工作,我可以尝试以下操作:

[UIView beginAnimations:nil context:nil];
            [UIView setAnimationDuration:0.6];
            [UIView setAnimationDelegate:self];
            [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.View2.superview cache:YES];
            [self.View2 removeFromSuperview];   
            [self performSelector:@selector(replaceViews2) withObject:nil afterDelay:0.6];
            [UIView commitAnimations];

您好,谢谢,但我想知道,大多数iphone应用程序使用从右到左的飞行效果,这是系统提供的功能吗?它无法工作,通过将我的代码更改为您的(上一个解决方案),视图就是无法显示。