ocultar la barra de navegación cuando se toca

I am making a slideshow for in my app. I want it almost like the photo app of Apple. It is almost finished just some small issues. I want to hide the navbar when tapped on the screen and show it when tapped again. But I am not sure how to do this.

preguntado el 08 de noviembre de 11 a las 12:11

4 Respuestas

// catch the screen tap and call a method to hide the navigation bar
UITapGestureRecognizer *gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toggleNavBar:)];
[self.view addGestureRecognizer:gesture];
[gesture release];

- (void)toggleNavBar:(UITapGestureRecognizer *)gesture {
    BOOL barsHidden = self.navigationController.navigationBar.hidden;
    [self.navigationController setNavigationBarHidden:!barsHidden animated:YES];
}

respondido 08 nov., 11:16

do you know how to make the navbar transparent and 1 more small problem is when the nav bar fades the image scrolls a bit up. Do you know how to fix this? Thanks in advance. - Dawid

How do you want to hide the navigation bar? Tapping in the navigation bar (which would be quite tricky, if not downright impossible) or via some other button or via another method?

In general, you can definitely hide the navigation bar.

Revisa [UINavigationController setNavigationBarHidden: animated:] (I've linked the Apple documentation)

respondido 08 nov., 11:16

I want to hide the navbar when tapped on the screen. Just as in the photo app of iPhone. - Dawid

Jano's answer should do what you're looking for, then. :-) - Michael Dautermann

  1. Add Gesture to Screen using

UITapGestureRecognizer *theSingleTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self

action:@selector(handleSingleTapForImage:)]; [inImageView addGestureRecognizer:theSingleTapGesture]; [theSingleTapGesture release];

  1. In gesture method show or hide NavigationBar

    -(void)handleSingleTapForImage:(UITapGestureRecognizer *)sender {
    [self.navigationController setNavigationBarHidden:![self.navigationController isNavigationBarHidden] animated:YES];
    

    }

respondido 08 nov., 11:16

Make navigation translucent

self.navigationController.navigationBar.barStyle=UIBarStyleBlackTranslucent; 

Respondido el 23 de junio de 12 a las 15:06

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.