2011-09-13 9 views
0

新しいメッセージを作成するとき、iphoneはアニメーションを使用します(新しいビューは画面の下部から表示されます)。そのアニメーションをアプリケーションに追加したいと思います。しかし、あらかじめ定義されたトランジションアニメーションタイプではそれを見つけることはできません。 どうすれば追加できますか?
私に助けてください。ビュー間の遷移をアニメーション化する方法は?

答えて

6

あなたはこのような他のUIViewControllersに切り替えることができます。このメソッドが呼び出され

[self presentModalViewController:yourUIViewController animated:YES]; 

のようなアニメーションの多くの種類があります...

yourUIViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; 
[self presentModalViewController:yourUIViewController animated:YES]; 

yourUIViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; 
    [self presentModalViewController:yourUIViewController animated:YES]; 

yourUIViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical; 
[self presentModalViewController:yourUIViewController animated:YES]; 
+0

+1また、iOS 5.0以降では、[UIViewController presentViewController:animated:completion:]もあります。これを行うのが好ましい方法だけでなく、より多くのオプションをもっと簡単に与えるだけです(完了ブロックではアニメーションが終了した後***のアクションをキューに入れることができます)!!! – mbm29414

0

これは、何が必要です:あなたはそれを下から来るようにするために、このモーダルトランジションのスタイルを指定する必要があなたの場合は

- (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated; 

UIViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical; 
[self presentModalViewController:yourUIViewController animated:YES]; 
+0

を参照してください。 – Joze

0

あなたは意見を両立させるべきではありません直接。トップレベルのビューにはビューコントローラが関連付けられている必要があります(コントローラはpresentModalViewController:animated:メソッドのように)。

-1
   - (void) buttonTouch 
     { 
     myView *Obj=[[myView alloc]init]; 
     [self presentModalViewController:Obj animated:YES]; 


     } 

 - (void) buttonTouch 

sの下から上にスライドするmyViewを表示しますメール作成者やメッセージ作成者のようなクレン。

  -(void) dismissmyView 
      { 
       [self dismissModalViewControllerAnimated:YES]; 
      } 

     -(void) dismissmyView 

それは却下されますと呼ばれるか、これはあなたには、いくつかの遅延と異なるビュー間の遷移をアニメーション化する方法である現在のModalView
すなわちMYVIEW

0

をキャンセルするこの方法。

- (void)viewsAction:(id)sender 
{ 

    First *first = [[First alloc] init]; 

    first.view.frame = CGRectMake(0, 0, 320, 425); 

    CATransition *transitionAnimation = [CATransition animation]; 

    [transitionAnimation setDuration:1]; 

    [transitionAnimation setType:kCATransitionFade]; 

    [transitionAnimation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]]; 

    [first.view.layer addAnimation:transitionAnimation forKey:kCATransitionFade]; 

    [self.view addSubview:first.view]; 

    [first release]; 

     self.timer = [NSTimer scheduledTimerWithTimeInterval:23 target:self selector:@selector(Second) userInfo:nil repeats:NO]; 

    } 

    -(void)Second 
{ 
    Second *second = [[Second alloc] init]; 

second.view.frame = CGRectMake(0, 0, 320, 425); 

CATransition *transitionAnimation = [CATransition animation]; 

[transitionAnimation setDuration:1]; 

[transitionAnimation setType:kCATransitionPush]; 

[transitionAnimation setSubtype:kCATransitionFromRight]; 

[transitionAnimation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; 

[second.view.layer addAnimation:transitionAnimation forKey:kCATransitionPush]; 

[self.view addSubview:second.view]; 

    [second release]; 

self.timer = [NSTimer scheduledTimerWithTimeInterval:27 target:self selector:@selector(Third) userInfo:nil repeats:NO]; 
} 

希望します。

関連する問題