Here's an example of what I'm doing:
In the calling ViewController I use the following code to switch views:
-(void)selectProfile:(User*)selectedUser{
SelectGameViewController* selectGame=[[SelectGameViewController alloc]initWithNibName:@"SelectGame" bundle:nil];
UIView* parent=self.view.superview;
[UIView beginAnimations:@"Show selection" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationDuration:0.50f];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:parent cache:YES];
[selectGame viewWillAppear:YES];
[self viewWillDisappear:YES];
[parent insertSubview:selectGame.view atIndex:0];
[self.view removeFromSuperview];
[selectGame viewDidAppear:YES];
[self viewDidDisappear:YES];
[UIView commitAnimations];
}
Then in the appearing view, I have the following code in the -viewWillAppear method:
-(void)viewWillAppear:(BOOL)animated{
UIButton* newButton=[[UIButton alloc]initWithFrame:CGRectMake(50, 150, 500, 150)];
[newButton setTitle:@"Play" forState:UIControlStateNormal];
[newButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
[newButton.titleLabel setFont:[UIFont fontWithName:@"EraserDust" size:80]];
[newButton addTarget:self action:@selector(playGame:) forControlEvents:UIControlEventTouchUpInside];
newButton.transform = CGAffineTransformMakeRotation(-.2);
[self.view addSubview:newButton];
[newButton release];
[super viewWillAppear:animated];
}
The outcome of this is that the view appears with the button unrotated, but then immediately after it's displayed it rotates. I'm very confused as this doesn't seem at odds with TechZen's suggestion?