2010-12-22 6 views
1

also zwischen Ansichten wechseln ich versuche, diesen Code zu verwenden:Problem CATransitions Mit Ansichten wechseln

CATransition *applicationLoadViewIn = [CATransition animation]; 

    [applicationLoadViewIn setDuration:1]; 

    [applicationLoadViewIn setType:kCATransitionReveal]; 

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

    MyViewControllerClass *theControllerIAmSwitchingTo = [[MyViewControllerClass alloc] init]; 

    [[theControllerIAmSwitchingTo.view layer] addAnimation:applicationLoadViewIn forKey:kCATransitionReveal]; 

Aber, wird der Code nicht. Es gibt keine Fehler, und der Code funktioniert gut, aber es tut nichts. Was habe ich hier falsch?

+0

Testen Sie es am Simulator? –

+0

Ja, ...., ...... – Regan

+0

Ich habe eine Antwort geschrieben, bitte sehen Sie sich das an. –

Antwort

1

Sie müssen die Animation zur Ebene der übergeordneten Ansicht hinzufügen und dann die Ansicht als Unteransicht der übergeordneten Ansicht hinzufügen.

Also statt

[[theControllerIAmSwitchingTo.view layer] addAnimation:applicationLoadViewIn forKey:kCATransitionReveal]; 

Sie benötigen

[parentView.layer addAnimation:animation forKey:kCATransitionReveal]; 
[parentView addSubview:theControllerIAmSwitchingTo.view]; 
1

einfach zu bedienen mögen es:

CATransition *applicationLoadViewIn = [CATransition animation]; 

    [applicationLoadViewIn setDuration:1]; 

    [applicationLoadViewIn setType:kCATransitionReveal]; 

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

    MyViewControllerClass *theControllerIAmSwitchingTo = [[MyViewControllerClass alloc] init]; 

    [[theControllerIAmSwitchingTo.view layer] addAnimation:applicationLoadViewIn forKey:kCATransitionReveal]; 

    [self.navigationController pushViewController:theControllerIAmSwitchingTo animated:NO]; 

ich das Problem aufgefallen ist, dass Sie nicht Ihre Ansicht hinzufügen, in Ihr Navigationsstapel und deshalb wird Ihre Ansicht nicht geladen und Sie sehen keine Animation.

Verwandte Themen