Pergunta

Não consigo conseguir qualquer animação com o seguinte código:

if (self.segmentControl.selectedSegmentIndex == 0) {
    [UIView transitionFromView:tableView
                        toView:mapView
                      duration:1.0
                       options:UIViewAnimationTransitionFlipFromLeft
                    completion:nil
         ];
    }
if (self.segmentControl.selectedSegmentIndex == 1) {
    [UIView transitionFromView:mapView
                        toView:tableView
                      duration:1.0
                       options:UIViewAnimationTransitionFlipFromRight
                    completion:nil
         ];
}

As vistas estão realmente trocando, mas apenas sem qualquer animação. É muito estranho. Eu também tentei trocar mapView e tableView com self.view.subviews igual a (objectAtIndex:0 é um toolBar):

if (self.segmentControl.selectedSegmentIndex == 0) {
    [UIView transitionFromView:[self.view.subviews objectAtIndex:1]
                        toView:[self.view.subviews objectAtIndex:2]
                      duration:1.0
                       options:UIViewAnimationTransitionFlipFromLeft
                    completion:nil
         ];
    }
if (self.segmentControl.selectedSegmentIndex == 1) {
    [UIView transitionFromView:[self.view.subviews objectAtIndex:2]
                        toView:[self.view.subviews objectAtIndex:1]
                      duration:1.0
                       options:UIViewAnimationTransitionFlipFromRight
                    completion:nil
         ];
}
Foi útil?

Solução

Você está usando as opções erradas. Com este método, você deve usar as constantes UIViewAnimationOpçãoTransitionFlipFromLeft e …Right em vez de.

As antigas constantes UIViewAnimationTransitionFlipFromLeft e …Right só deve ser usado para o método não baseado em blocos +setAnimationTransition:…. Essas constantes têm valores 1 e 2, respectivamente, enquanto as que mencionei acima têm valores 1 << 20 e 2 << 20, que são totalmente diferentes.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top