2012-04-26 9 views
0

これは私がこれまで行ってきたことです。私がしようとしているのは、新しいビューで画面をスライドさせることによって、開始ビュー(startUpView)を他のビュー(creatNewGameViewController)に切り替えることです。現在は、通常はビューを切り替えるだけですが、実際にはそのスライド効果が必要です。誰かが私のコードでエラーを見つけることができれば、それは非常に高く評価されるだろう。おかげUIViewアニメーションスワップビュー(スライドダウン)

#import "CreateNewGameViewController.h" 
@synthesize createNewGameViewController; 
UIButton *mainCreateGame = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
[mainCreateGame addTarget:self 
        action:@selector(goToCreateGameViewController) 
     forControlEvents:UIControlEventTouchUpInside]; 
[mainScroll addSubview:mainCreateGame]; 
mainCreateGame.frame = CGRectMake(65, 10, 190, 60); 

-(void)goToCreateGameViewController{ 
CreateNewGameViewController *newGame = [[CreateNewGameViewController alloc]initWithNibName:@"CreateNewGameViewController" bundle:nil]; 
self.createNewGameViewController = newGame; 

CATransition *transition = [CATransition animation]; 
transition.duration = 2; 
transition.timingFunction = [CAMediaTimingFunction  
          functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 
transition.type =kCATransitionMoveIn; 


CATransition *transition1 = [CATransition animation]; 
transition1.duration = 2; 
transition1.timingFunction = [CAMediaTimingFunction  
          functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 
transition1.type =kCATransitionMoveIn; 
transition1.subtype =kCATransitionFromTop; 

transition1.delegate = self; 

[createNewGameViewController.view.layer addAnimation:transition1 forKey:nil]; 
transition1.subtype =kCATransitionFromTop; 

transition1.delegate = self; 



[self presentModalViewController:newGame animated:NO]; 
[self.view insertSubview:newGame.view atIndex:0]; 

[createNewGameViewController.view.layer addAnimation:transition1 forKey:nil]; 

[newGame release]; 
+0

presentModalViewController:animated:潜在的に新しいビューを古いものの上に配置しますか?また、ビューを提示し、そのビューを挿入することは多少 'ハックアップ'のようです –

答えて

0

はUIViewのは、アニメーションを表示するビューからの移行と呼ばれるクラスのメソッドを持っている、それが助け、それがアドバイス:)

UiView

一枚だったかを教えている場合、あなたが本当にすべきチェックナビゲーションコントローラ、ストーリーボードなどを使用して、適切な方法であるため、そのようなビュー遷移を行うことができます。

+0

あなたはどういう意味ですか?私はこのようなものに新しいので、私はこのものの半分のために使用する必要があります(または理由)私はかなり確信していません。 – nfoggia

+0

ios SDKはMVCに向けられており、 –

関連する問題