2009-09-10 16 views
0

Je l'ai placé le code suivant dans mon programmeappelant une animation?

CATransition *animation = [CATransition animation]; 
[animation setDuration:0.5]; 
[animation setType:kCATransitionFade]; 
[animation setSubtype:kCATransitionFromLeft]; 
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; 
    [[theWindow layer] addAnimation:animation forKey:@"SwitchToView1"]; 

Tout fonctionne très bien, mais il n'y a pas d'animation quand je construis le projet dans le simulateur.

Où et comment appeler cette animation? une fois que je reçois cela, je peux le soumettre à l'app store!

+0

Quelle langue et la plate-forme est ce code pour? –

+0

Xcode pour la transition iphone – Dane

Répondre

1

Avez-vous des vues dans votre application ou juste une fenêtre? Je me demande simplement si vous ajoutez l'animation sous tout le reste. Dans la plupart de mes applications et de nombreux exemples d'Apple, il y a une MainWindow sous-jacente et toutes les vues sont additionnées en utilisant ViewControllers ou d'autres contrôleurs.

Aussi, avez-vous pensé à utiliser le plus simple beginAnimation ... commitAnimation?

Si vous êtes simplement essayer d'animer l'ajout d'une vue et la suppression d'une autre, voir mon code pour ce faire avec viewControllers:

- (void)switchTwoViews:(UIViewController *)view1 otherView:(UIViewController *)view2 cacheTheView:(BOOL) cache; 
{ 
    /* 
    This method is called when the info or Done button is pressed. 
    It flips the displayed view from the main view to the flipside view and vice-versa. 
    */ 

    UIViewController *coming = nil; 
    UIViewController *going = nil; 
    UIViewAnimationTransition transition; 

    [view1.view setUserInteractionEnabled: NO]; 
    [view2.view setUserInteractionEnabled: NO]; 
    if (view1.view.superview == nil) { 
     coming = view1; 
     going = view2; 
     transition = UIViewAnimationTransitionFlipFromLeft; 
    } 
    else { 
     coming = view2; 
     going = view1; 
     transition = UIViewAnimationTransitionFlipFromRight; 
    } 
    // [coming.view setFrame:CGRectMake(0, 0, 480, 320)]; 


    NSArray *viewArray = [[NSArray alloc] initWithObjects:coming, going, nil]; 
    [coming viewWillAppear:YES]; 
    [going viewWillDisappear:YES]; 
    [UIView beginAnimations:@"View Flip" context:viewArray]; { 
     [UIView setAnimationDuration:1.0]; 
     [UIView setAnimationDelegate:self]; 
     [UIView setAnimationDidStopSelector:@selector(animationDidEnd:finished:context:)]; 
     [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 

     [UIView setAnimationTransition:transition forView:self.view cache:cache]; 
     [self.view addSubview: coming.view]; 
    } 
    [UIView commitAnimations]; 

} 
- (void) animationDidEnd:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context 
{ 
    NSArray *viewArray = context; 
    [((UIViewController *)[viewArray objectAtIndex:1]).view removeFromSuperview]; 
    [[viewArray objectAtIndex:1] viewDidDisappear:YES]; 
    [[viewArray objectAtIndex:0] viewDidAppear:YES]; 
    [[[viewArray objectAtIndex:0] view] setUserInteractionEnabled: YES]; 
    [viewArray release]; 
} 
+0

non je n'ai pas! S'il vous plaît jeter un oeil à mon code complet. ici. J'ai vraiment besoin de cela résolu! Je vous remercie! http://www.iphonedevsdk.com/forum/iphone-sdk-development/28174-transitions-fading.html#post122649 – Dane

+0

1 vue principale avec une vue slidecontroller – Dane

+0

Je vais utiliser n'importe quoi. faites le moi savoir! – Dane