title: Flipping Subviews above a main view
body: <p>I'm trying to build a subview that sits above my main view that is approximately 3/4 the size of the main view.  When a button is pressed, the subview should flip to another subview.  I'm close, but am having TWO problems.</p>
  
  <p>The first problem is that the first time the flip button is pressed, the second subview starts at full screen and shrinks to the specified frame size rather than any flipping animations being rendered.</p>
  
  <p>Once the second view is rendered, I can then flip between the first and second views (I added a second button to flip back for testing purposes).  </p>
  
  <p>My second issue is that when the view flips, the new view is loaded before the flip, and then the flipping occurs.  I've built flipping views before that have worked correctly, but only when the entire screen was the view.</p>
  
  <p>Here's my code that is in my main view controller:</p>
  
  <pre><code>- (void)viewDidLoad {
  
      Page1Controller *myPage1=[[Page1Controller alloc] initWithNibName:@"Page1Controller" bundle:nil];
      Page2Controller *myPage2=[[Page2Controller alloc] initWithNibName:@"Page2Controller" bundle:nil];
      self.page1 = myPage1;
      self.page2 = myPage2;
      [myPage1 release];
      [myPage2 release];
      [[page1 view] setFrame:CGRectMake(45, 40, 230, 280)];
      [[self view] addSubview:[page1 view]];
  
      [super viewDidLoad];
  }
  </code></pre>
  
  <p>And here is the code for the two buttons:</p>
  
  <pre><code>- (void)flipPressed:(id)sender {
      [UIView beginAnimations:@"View Flip" context:nil];
      [UIView setAnimationDuration:1.5];
      [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:[page2 view] cache:YES];
      [page1.view removeFromSuperview];
      [[page2 view] setFrame:CGRectMake(45, 40, 230, 280)];
      [[self view] addSubview:[page2 view]];
  
      [UIView commitAnimations];
  
  }
  
  - (void)backFlipPressed:(id)sender {
      [UIView beginAnimations:@"View Flip" context:nil];
      [UIView setAnimationDuration:1.5];
      [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:[page1 view] cache:YES];
      [page2.view removeFromSuperview];
      [[self view] addSubview:[page1 view]];
      [[page1 view] setFrame:CGRectMake(45, 40, 230, 280)];
  
      [UIView commitAnimations];
  }
  </code></pre>
  
  <p>Any help on either of my issues is greatly appreciated!</p>