I’m having some trouble getting a view to flip. I have the following code in my View Controller:
- (void)loadFlipsideViewController { ProblemViewFlipController *viewController = [[ProblemViewFlipController alloc] initWithNibName:@'ProblemViewFlip' bundle:nil]; self.problemViewFlipController = viewController; [viewController release]; } - (void) flipView { if (problemViewFlipController == nil) { [self loadFlipsideViewController]; } UIView *mainView = self.view; UIView *flipView = problemViewFlipController.view; [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:1]; [UIView setAnimationTransition:([mainView superview] ? UIViewAnimationTransitionFlipFromLeft : UIViewAnimationTransitionFlipFromRight) forView:self.view cache:YES]; if ([flipView superview]) { [flipView removeFromSuperview]; [self.view addSubview:mainView]; } else { [mainView removeFromSuperview]; [self.view addSubview:flipView]; } [UIView commitAnimations]; }
The problem is, is that when I call flipView, the view is replaced with a blank view (i.e. nothing in the view I’m flipping to is displayed).
Is there something obvious I’m missing here? (I suspect there is!)
Not positive, but I think you need to use a ‘controller’ to flip the views. Looks like you’re using one of the flipped views as the controller. Just add a root controller to flip your views.
Code like this should work from the root controller: