简体   繁体   English

在iPhone中使用动画切换视图

[英]Switching views with animation in iPhone

I'm trying to create a simple animation when switching from a view to another in iPhone. 我试图在iPhone中从视图切换到另一个视图时创建一个简单的动画。

I have a controller with its view. 我有一个控制器,其观点。 In the same xib file I placed another view I called viewTracks. 在同一个xib文件中,我放置了另一个名为viewTracks的视图。 I would like to write an action that switches from the default view of the controller to the view viewTracks. 我想写一个动作,将控制器的默认视图切换到viewTracks视图。 This is the code of the action I wrote in my controller: 这是我在控制器中编写的操作代码:

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:[self view] cache:YES];
UIView* sup = [[self view] superview];
[self.view removeFromSuperview];
[sup addSubview:viewTracks];
[UIView commitAnimations];

All I see is that the view does switch, but without any animation. 我所看到的只是视图确实切换了,但是没有任何动画。 Is there any mistake here? 这里有什么错误吗? Why do I see the correct switch of view without an the animation I specified? 为什么我没有指定的动画就能看到正确的视图切换? Thanks! 谢谢!

我建议将要切换的两个视图设为视图控制器视图的子视图。

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

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