I’m trying to create a simple animation when switching from a view to another in iPhone.
I have a controller with its view. In the same xib file I placed another view I called viewTracks. I would like to write an action that switches from the default view of the controller to the view 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!
I would recommend making the the two views you want to switch between be subviews of your view controller’s view.