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

  • SEARCH
  • Home
  • 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 6742675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:52:17+00:00 2026-05-26T11:52:17+00:00

I have a tabbar application, in one of the tabs I have a MKMapView.

  • 0

I have a tabbar application, in one of the tabs I have a MKMapView. In this view, my viewDidLoad I am initializing a long press gesture recognizer for a UIButton. When this button is pressed and help it presents a UIActionSheet with 5 buttons + the cancel button. Each button represents a zoom level: “World”, “Country”, “State”, “City”, “Current Location”. Selecting a button in the UIActionSheet zooms the underlying MKMapView to that level.

The problem I am having is that all of the buttons (including the cancel button) require double-tapping to dismiss the UIActionSheet. This is not the intended behavior — it should dismiss after pressing the button once like every other UIActionSheet. After the first press I can see the map zooming to the appropriate level behind the UIActionSheet so I know the touch is registering on the correct button, but the button does not highlight blue upon the first press and the UIActionSheet does not dismiss. Not until I press the button for a second time does it highlight blue and then dismiss.

If I remove the longpress gesture recognizer and present the UIActionSheet on a ‘touch up inside’ then everything works as it is supposed to. So I know the gesture is somehow interfering, any ideas on a fix or workaround? Or is this a bug that should be reported to Apple?

- (void) viewDidLoad {
    // intitialize longpress gesture
    UILongPressGestureRecognizer *longPressRecognizer = [[UILongPressGestureRecognizer alloc]
                                                         initWithTarget:self 
                                                         action:@selector(zoomOptions:)];
    longPressRecognizer.minimumPressDuration = 0.5;
    longPressRecognizer.numberOfTouchesRequired = 1;
    [self.currentLocationButton addGestureRecognizer:longPressRecognizer];
}

- (IBAction) zoomOptions:(UIGestureRecognizer *)sender {
    NSString *title = @"Zoom to:";
    UIActionSheet *zoomOptionsSheet = [[UIActionSheet alloc] initWithTitle:title delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"World", @"Country", @"State", @"City", @"Current Location", nil];  

    [zoomOptionsSheet showFromTabBar:appDelegate.tabbarController.tabBar];
}
  • 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-05-26T11:52:18+00:00Added an answer on May 26, 2026 at 11:52 am

    Anna Karenina was right, and the link provided helped me figure it out. Basically, UILongPressGestureRecognizer is a “continuous gesture” which undergoes various state changes. I needed to check for the appropriate state, which in my case is UIGestureRecognizerStateBegan since I want the UIActionSheet presented after holding the button down but before you release and stop the gesture. All I had to do was wrap the presentation of the UIActionSheet in an if statement that checked for the appropriate state. Now it works as expected.

    - (IBAction) zoomOptions:(UILongPressGestureRecognizer *)sender {
        if (sender.state == UIGestureRecognizerStateBegan) {
            NSString *title = @"Zoom to:";
            UIActionSheet *zoomOptionsSheet = [[UIActionSheet alloc] 
                                                initWithTitle:title 
                                                     delegate:self 
                                            cancelButtonTitle:@"Cancel"
                                       destructiveButtonTitle:nil 
                                            otherButtonTitles:@"World", @"Country",                
                                                              @"State", @"City", 
                                                              @"Current Location", nil];  
            [zoomOptionsSheet showFromTabBar:appDelegate.tabbarController.tabBar];
        } 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tab bar application and when i press on one of the tabs
I have an iPhone application with Tabbar. One of the tabs is UIWebView which
I am working with a tabbar application. In one of the tabs I have
I've got a TabBar application and 2 views. One view is a MKMapView with
I have developed a tabBar application in iphone,it uses 4 tabs to show the
I have following problem: I have built a tabbar application with 4 tabs. I
I have a tabBar App, with 5 tabs. The application was built in previous
I have a tabbar application that has one screen that displays statistics based on
I have a simple Android application that has a TabBar and one of the
I have a UITabBar based application, on one TabBar Button I have a navigation

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.