Je crée une application qui affiche/cache (dans une animation personnalisée) le UINavigationBar en un seul clic.Animation personnalisée lors de la dissimulation de UINavigationBar
J'ai créé deux fonctions (une pour montrer et l'autre pour se cacher). La fonction pour montrer la UINavigationBar fonctionne parfaitement:
- (void) showNavigationBar {
[UINavigationBar beginAnimations:@"NavBarFadeIn" context:nil];
self.navigationController.navigationBar.alpha = 0;
[UINavigationBar setAnimationCurve:UIViewAnimationCurveEaseIn];
[UINavigationBar setAnimationDuration:0.5];
[UINavigationBar setAnimationTransition:UIViewAnimationOptionTransitionFlipFromTop
forView:self.navigationController.navigationBar
cache:YES];
self.navigationController.navigationBar.alpha = 1;
[UINavigationBar commitAnimations];
}
Mais la fonction pour cacher, même si elle est la même chose, ne fonctionne pas. Le UINavigationBar disparaît soudainement sans animation.
- (void) hideNavigationBar {
[UINavigationBar beginAnimations:@"NavBarFadeOut" context:nil];
self.navigationController.navigationBar.alpha = 1;
[UINavigationBar setAnimationCurve:UIViewAnimationCurveEaseIn];
[UINavigationBar setAnimationDuration:0.5];
[UINavigationBar setAnimationTransition:UIViewAnimationOptionTransitionCurlUp
forView:self.navigationController.navigationBar
cache:YES];
self.navigationController.navigationBar.alpha = 0;
[self.navigationController setNavigationBarHidden:YES animated:NO];
[UINavigationBar commitAnimations];
}
L'appel:
- (void)contentView:(ReaderContentView *)contentView touchesBegan:(NSSet *)touches
{
if([[self navigationController] isNavigationBarHidden] == NO)
{
if (touches.count == 1) // Single touches only
{
UITouch *touch = [touches anyObject]; // Touch info
CGPoint point = [touch locationInView:self.view]; // Touch location
CGRect areaRect = CGRectInset(self.view.bounds, TAP_AREA_SIZE, TAP_AREA_SIZE);
if (CGRectContainsPoint(areaRect, point) == false) return;
}
[mainToolbar hideToolbar];
[mainPagebar hidePagebar]; // Hide
[self hideNavigationBar];
lastHideTime = [NSDate new];
}
}
Tout le monde a la moindre idée de pourquoi cela se passe?
Pouvez-vous envoyer le code où vous appelez -showNavigationBar et hideNavigationBar –
je viens édité et inclus le code d'appel – crisisGriega