No bloque de animación UIView subvistas de ver la animación
-
27-09-2019 - |
Pregunta
Soy incapaz de lograr cualquier animación con el siguiente 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
];
}
Las vistas son realmente Oral, pero sólo sin ningún tipo de animación. Es bastante extraño. También he tratado de mapView
swap y tableView
con self.view.subviews
como tal (objectAtIndex:0
es un 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
];
}
Solución
Está utilizando las opciones equivocadas. Con este método, se debe utilizar las constantes UIViewAnimationOptionTransitionFlipFromLeft
y …Right
su lugar.
El UIViewAnimationTransitionFlipFromLeft
constantes viejos y …Right
sólo deben utilizarse para la +setAnimationTransition:…
método no basado en bloque. Estas constantes tienen los valores 1 y 2, respectivamente, mientras que los que he mencionado anteriormente tienen valores de 1 << 20 y 2 << 20, que son totalmente diferentes.