J'applique un CAAnimation
pour déplacer une barre d'outils sur et hors écran.Durée CAAnimation non appliquée
Quand je touche le superview, que les feux de la méthode suivante:
- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
[UIView beginAnimations:kViewerToggleToolbarAnimation context:nil];
if (self.viewerToolbarView.isVisible) {
self.viewerToolbarView.frame = CGRectMake(0, self.frame.size.height, self.viewerToolbarView.frame.size.width, self.viewerToolbarView.frame.size.height);
self.viewerToolbarView.isVisible = NO;
}
else {
self.viewerToolbarView.frame = CGRectMake(0, self.frame.size.height - kUIToolbarHeight, self.viewerToolbarView.frame.size.width, self.viewerToolbarView.frame.size.height);
self.viewerToolbarView.isVisible = YES;
}
[UIView commitAnimations];
}
Cela feux de la méthode de délégué du sous-vue:
- (id<CAAction>) actionForLayer:(CALayer *)layer forKey:(NSString *)key {
id<CAAction> animation = nil;
if ([key isEqualToString:kViewerToggleToolbarAnimation]) {
animation = [CABasicAnimation animation];
if (self.isVisible)
((CABasicAnimation*)animation).duration = kViewerToolbarHideAnimationDuration;
else
((CABasicAnimation*)animation).duration = kViewerToolbarShowAnimationDuration;
((CABasicAnimation*)animation).timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];
}
else {
animation = [super actionForLayer:layer forKey:key];
}
return animation;
}
Les constantes kViewerToggleToolbarAnimation
, kViewerToolbarHideAnimationDuration
et kViewerToolbarShowAnimationDuration
sont définis ailleurs comme :
extern NSString * const kViewerToggleToolbarAnimation;
extern CGFloat const kViewerToolbarShowAnimationDuration;
extern CGFloat const kViewerToolbarHideAnimationDuration;
...
NSString * const kViewerToggleToolbarAnimation = @"kViewerToggleToolbarAnimation";
CGFloat const kViewerToolbarShowAnimationDuration = 2.50f;
CGFloat const kViewerToolbarHideAnimationDuration = 2.75f;
Le problème est que je peux augmenter ces valeurs de durée dans le fichier de constantes, mais la méthode déléguée ignore ces durées et applique sa propre durée notablement courte (0,5 sec, environ).
2.5 et 2.75 sec sont des temps assez remarquablement longs dans lesquels l'animation fonctionnerait autrement, si elle fonctionnait correctement. Qu'est-ce que je fais de mal à propos du déclenchement de l'animation, ce qui provoque l'ignorance de ces constantes de durée? Il compile et fonctionne bien, donc il ne se plaint pas de ne pas pouvoir trouver les constantes.