Hola en respuesta a los eventos táctiles, mi aplicación no ve la animación. Si el usuario es realmente rápido y hace otro toque incluso mientras se desarrolla la animación actual, todo se complica.Sincronización de animaciones de UIView
¿Existe una forma estándar de manejar este problema proporcionado por el marco? ¿O estoy haciendo la animación de una manera incorrecta?
Actualmente está revisando una bandera (animationInProgress) para manejar esto, pero quería saber si eso es lo que tenemos que recurrir para esto.
Aquí está el código:
- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
NSMutableArray *c = (NSMutableArray*)context;
UINavigationController *nc = [c objectAtIndex:0];
[nc.view removeFromSuperview];
animationInProgress = NO;
}
- (void)transitionViews:(BOOL)topToBottom {
if (animationInProgress) {
return;
}
animationInProgress = YES;
NSMutableArray *context = [[NSMutableArray alloc] init];
[UIView beginAnimations:@"myanim" context:context];
[UIView setAnimationDuration:0.7f];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
UIViewController *from;
UIViewController *to;
if (navController3.view.superview == nil) {
from = navController2;
to = navController3;
} else {
from = navController3;
to = navController2;
}
int height;
if (topToBottom) {
height = -1 * from.view.bounds.size.height;
} else {
height = from.view.bounds.size.height;
}
CGAffineTransform transform = from.view.transform;
[UIView setAnimationsEnabled:NO];
to.view.bounds = from.view.layer.bounds;
to.view.transform = CGAffineTransformTranslate(transform, 0, height);
[window addSubview:to.view];
[UIView setAnimationsEnabled:YES];
from.view.transform = CGAffineTransformTranslate(from.view.transform, 0, -1 * height);
to.view.transform = transform;
[context addObject:from];
[UIView commitAnimations];
return;
}
Si detiene los eventos táctiles al ingresar a su aplicación durante la animación usando begin/endIgnoringInteractionEvents, ¿qué sucede con los eventos táctiles que pueden llegar mientras está en este bloque? ¿Se guardarán en la memoria caché y se presentarán en la aplicación una vez que se ignoreInteractionEventsEvents o se descarten todos los toques (como su nombre lo sugiere)? – vance
@vance: serán desechados, como su nombre indica. –