2011-12-04 5 views
2

カスタムSegue TransitionでCATransitionを使用できるかどうかは疑問でした。私は自分のCustomSegueTransition.mファイルを作成し、カスタムセグエクラスでそれを参照して、どこに遷移を起こさせたいのですか?カスタムSegueでのCATVの変更

これはCustomSegueTransition.mファイルの私のコードです:

#import "CustomSegueTransition.h" 
#import "QuartzCore/QuartzCore.h" 

@implementation CustomSegueTransition 

-(void) perform { 

    // set up an animation for the transition the content 
    CATransition *animation = [CATransition animation]; 
    [animation setDuration:0.25]; 
    [animation setType:kCATransitionPush]; 
    [animation setSubtype:kCATransitionFromRight]; 
    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; 

    [UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationDuration:0.25]; 

    [UIView commitAnimations]; 
} 

@end 

それはボタンがセグエ遷移を起こすために押されたときしかし、文句を言わないの移行が実行、私に何のエラー警告を与えません。 CATransitionコードで何かが見つからないのですか?これは不可能ですか?

ありがとうございます!

答えて

1

@Grant

私はあなたのために完全な答えを持っていないが、私は、あなたが新しいビューを呼び出すことはありませんという通知は、このように何も変化はありませんでした。私は信じて

UIViewController *src = (UIViewController *) self.sourceViewController; 
UIViewController *dst = (UIViewController *) self.destinationViewController; 
[src presentModalViewController:dst animated:YES]; 

または

[src presentViewController:<#(UIViewController *)#> animated:<#(BOOL)#> completion:<#^(void)completion#>]; 

が他のがあります:私はあなたがプッシュ、ポップ、またはモーダルのために撮影しているが、ここであなたが追加する必要がありますコードのタイプがあるかどうかわかりません私は解決策に興味がありますが、答えがないカスタムアニメーションを設定する際の問題。

+1

'presentModalViewController:animated:'は推奨されていないので、この場合は 'presentViewController:animated:completion:'を使うべきです –

0

あなたが何をしようとしているのかよく分かりませんが、問題が見つかりました。

トランジションアニメーションを作成したことがありますが、使用したことはありません。アニメートするビューのレイヤーにアニメーションを追加する必要があります。

また、下部のCoreAnimation関数を使用する場合は、[UIView beginAnimation] ... [UIView commitAnimation]を使用する必要はありません。

必要に応じて[CATransaction begin] ... [CATransaction commit]を使用します。ここで

0

-(void)perform { 

__block UIViewController *sourceViewController = (UIViewController*)[self sourceViewController]; 
__block UIViewController *destinationController = (UIViewController*)[self destinationViewController];      

CATransition* transition = [CATransition animation]; 
transition.duration = .25; 
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 
transition.type = kCATransitionMoveIn; //kCATransitionMoveIn; //, kCATransitionPush, kCATransitionReveal, kCATransitionFade 
transition.subtype = kCATransitionFromLeft; //kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom 

[sourceViewController.navigationController.view.layer addAnimation:transition 
              forKey:kCATransition]; 

[sourceViewController.navigationController pushViewController:destinationController animated:NO]; 

} 
0

輸入QuartzCoreフレームワークを動作する完全なコードです。

- (void)pushViewWithCustomTranstion { 
    CATransition* transition = [CATransition animation]; 
    transition.duration = 0.4f; 
    transition.type = kCATransitionMoveIn; 
    transition.subtype = kCATransitionFromRight; 
    [self.navigationController.view.layer addAnimation:transition 
               forKey:kCATransition]; 
    YourDestinataionController *yourVC = [[YourDestinataionController alloc] init]; 
    [self.navigationController pushViewController:yourVC animated:NO]; 
} 

カスタムトランジション効果とナビゲーションコントローラにビューコントローラをプッシュするシンプルで簡単なコードです。

関連する問題