2011-11-06 2 views

Répondre

8

Il est possible, regardez le code suivant que j'ai utilisé il y a quelque temps et essayez de le faire fonctionner pour vous-même. Yu seulement besoin de changer le setAnimationTransition

[UIView beginAnimations:nil context:NULL]; 
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 
[UIView setAnimationDuration:0.75]; 
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO]; 
[UIView commitAnimations]; 

[UIView beginAnimations:nil context:NULL]; 
[UIView setAnimationDelay:0.375]; 
[self.navigationController popViewControllerAnimated:NO]; 
[UIView commitAnimations]; 

Il y a quelques différents types d'animations par défaut à utiliser, le site pommes dit ce genre d'animations sont possibles:

typedef enum { 
    UIViewAnimationTransitionNone, 
    UIViewAnimationTransitionFlipFromLeft, 
    UIViewAnimationTransitionFlipFromRight, 
    UIViewAnimationTransitionCurlUp, 
    UIViewAnimationTransitionCurlDown, 
} UIViewAnimationTransition; 

Donc, dans votre cas, vous voulez pour utiliser ce qui suit:

[UIView beginAnimations:nil context:nil]; 
    [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut]; 
    [UIView setAnimationDuration:0.75]; 
    [self.navigationController popViewControllerAnimated:NO]; 
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO]; 
    [UIView commitAnimations]; 
+0

Merci. Est-il possible de le faire glisser comme si vous appeliez 'pushViewController'? – Mason

+0

Oui, comme je l'ai dit, il suffit de changer la ligne ici: [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft pourView: self.navigationController.view cache: NO]; – Wesley

+0

Je comprends cela. Je ne peux pas trouver la transition correcte cependant. – Mason

16

C'est ainsi que l'on peut voir le contrôleur dans le sens opposé. Son travail pour moi 100%

CATransition *transition = [CATransition animation]; 
    transition.duration = 0.45; 
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]; 
    transition.type = kCATransitionFromRight; 
    [transition setType:kCATransitionPush]; 
    transition.subtype = kCATransitionFromRight; 
    [self.navigationController.view.layer addAnimation:transition forKey:nil]; 
    [self.navigationController popViewControllerAnimated:NO]; 
+0

c'est ce que je cherchais !! Merci. – iChirag

+2

Vous définissez le type deux fois? 'transition.type = kCATransitionPush' devrait suffire. –

Questions connexes