これが私がやっていることの例です:
呼び出し元の ViewController で、次のコードを使用してビューを切り替えます。
-(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];
}
次に、表示されるビューで、-viewWillAppear メソッドに次のコードがあります。
-(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];
}
この結果、ビューはボタンが回転していない状態で表示されますが、表示された直後に回転します。これはTechZenの提案と矛盾していないように見えるので、私は非常に混乱していますか?