Search code examples
objective-cios5uitoolbar

Show/Hide UIToolbar on single tap


I would be really grateful if someone could explain how to show/ Hide UItoolbar and/or UINavigationBar by single taping. eg like in the fullscreen picture gallery. I would like to implement image gallery with controls on the toolbar which would be dissmissed/revealed by tapping once on the image.


Solution

  • I'd add a UIGestureRecognizer to the view you're wanting to tap.

        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTap)];
       [self.view addGestureRecognizer:tap]; 
    
    - (void)didTap
    {
      [self.navigationController setNavigationBarHidden:YES animated:YES];
    //Or if you aren't using a nav controller just someToolbar.hidden = YES;
    
    }