Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8629063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:42:24+00:00 2026-06-12T08:42:24+00:00

I would like to hide and show the navigation bar on tap like the

  • 0

I would like to hide and show the navigation bar on tap like the one in the photos app
BUT without losing the functionality of the MKMapView. the user should still be able to double tap for zoom, pinch and zoom and be able to select annotations.

I tried it with:

 UITapGestureRecognizer* tapRec = [[UITapGestureRecognizer alloc] 
                                  initWithTarget:self action:@selector(hideBar:)];
[self.myMKMapView addGestureRecognizer:tapRec];
[tapRec release];

But then the user can’t select annotations anymore!And it also hides on double taps.

Any ideas ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T08:42:25+00:00Added an answer on June 12, 2026 at 8:42 am

    I know, it’s almost exactly one year too late, but I hope somebody can make a use of it. Here’s how I did it, based on @Cocoanetics’s answer:

    BOOL                mapReceivedDoubleTap;
    

    …

    UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapMap:)];
    [tapGestureRecognizer setDelegate:self];
    [_mapView addGestureRecognizer:tapGestureRecognizer];
    [tapGestureRecognizer release];
    

    …

    // ignore annotations
    - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
        return (![[touch view] isKindOfClass:[MKAnnotationView class]]);
    }
    
    // take care of double taps for zoom
    - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer  shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
    
        if([otherGestureRecognizer isKindOfClass:[UITapGestureRecognizer class]]) {
            UITapGestureRecognizer *tr = (UITapGestureRecognizer *)otherGestureRecognizer;
            if(tr.numberOfTapsRequired == 2)
                mapReceivedDoubleTap = YES;
        }
    
        return NO;
    }
    
    - (void)didTapMap:(UITapGestureRecognizer *)tapGestureRecognizer {
    
        mapReceivedDoubleTap = NO;
    
        // hide/show on delay
        dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, .2f * NSEC_PER_SEC);
        dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
            if(!mapReceivedDoubleTap)
                [self.navigationController setNavigationBarHidden:!self.navigationController.navigationBarHidden animated:YES];
        });
    }
    

    Swift

    import MapKit
    
    class MapViewController: UIViewController, UIGestureRecognizerDelegate {
    
        @IBOutlet weak var myMapView: MKMapView!
    
        var mapReceivedDoubleTap = false
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(MapViewController.didTapMap(_:)))            
            tapGestureRecognizer.delegate = self            
            myMapView.addGestureRecognizer(tapGestureRecognizer)
        }
    
        // ignore annotations
        func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldReceiveTouch touch: UITouch) -> Bool {
            return !touch.isKindOfClass(MKAnnotationView)
        }
    
        // take care of double taps for zoom
        func gestureRecognizer(gestureRecognizer: UIGestureRecognizer,
                               shouldRecognizeSimultaneouslyWithGestureRecognizer otherGestureRecognizer: UIGestureRecognizer) -> Bool {
    
            if otherGestureRecognizer.isKindOfClass(UITapGestureRecognizer) {
                let tr = otherGestureRecognizer as! UITapGestureRecognizer
                if tr.numberOfTapsRequired == 2 {
                    mapReceivedDoubleTap = true
                }
            }
    
            return false
        }
    
        func didTapMap(gestureRecognizer: UIGestureRecognizer) {
    
            mapReceivedDoubleTap = false
    
            // hide/show on delay
            let popTime = dispatch_time(DISPATCH_TIME_NOW, Int64(0.2 * Double(NSEC_PER_SEC)))
            dispatch_after(popTime, dispatch_get_main_queue(), {
                if !self.mapReceivedDoubleTap {
                    self.navigationController?.setNavigationBarHidden(!(self.navigationController?.navigationBarHidden)!, animated: true)
                }
            })
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ipad app where i would like to hide and show a
I have a link and would like to show/hide ONE form. The first line
I would like to show and hide a div during hover and hover out.
In the following code I would like to hide Hello world but keep visible
I would like to hide and show a number of buttons at random which
I am using a custom title view and would like to show/hide a progressbar
I would like to hide a div when a button is clicked and show
I would like to show/hide fields based on whether a struts2 checkbox is checked
I would like to control the menu display (show/hide menu items) in my ASP.NET
I would like to call JavaScript functions to show/hide a loading animation when a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.