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 8764399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:01:25+00:00 2026-06-13T16:01:25+00:00

I have multiple annotations set up on an MKMapView. Instead of using map annotation

  • 0

I have multiple annotations set up on an MKMapView. Instead of using map annotation callouts when a pin is clicked, I instead want to animate a subview (self.detailView) up into the bottom of the screen, and move it back out when nothing is selected. When the user has a pin selected, and then selects another pin, I want my view to animate off screen, and then immediately animate back on screen (with different information corresponding to the newly selected annotation, of course).

Without thinking too hard, I tried what seemed like the easy thing to do – when annotation is selected, animate self.detailView onto screen, and when it is deselected, animate self.detailView off screen:

- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
{
    NSLog( @"selected annotation view" );

    [UIView animateWithDuration:0.2f
                          delay:0.0f
                        options:UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionAllowUserInteraction
                      animations:^{
                          [self.detailView setFrame:CGRectMake(0, 307, 320, 60)];       
                      }
                      completion:^(BOOL finished){                

                      }];
}

- (void)mapView:(MKMapView *)mapView didDeselectAnnotationView:(MKAnnotationView *)view
{
    NSLog( @"deselected annotation view" );

    [UIView animateWithDuration:0.2f
                          delay:0.0f
                        options:UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionAllowUserInteraction
                      animations:^{
                          [self.detailView setFrame:CGRectMake(0, 367, 320, 60)];       
                      }
                      completion:^(BOOL finished){

                      }];

}

This works fine when no pin is selected and the user selects a pin, and when a pin is selected and the user deselects it by clicking on empty space. Of course, the problem occurs when a pin is already selected: if the user then clicks on another pin, didDeselectAnnotationView and didSelectAnnotationView are fired in rapid succession, both animations try to run at the same time, and as a result the effect doesn’t work properly. Normally I would chain the animations together by putting the second animation in the completion block of the first, but since they are in separate methods I obviously can’t do that here.

Anyone have any ideas on how I might be able to get around this issue? Thanks!

  • 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-13T16:01:27+00:00Added an answer on June 13, 2026 at 4:01 pm

    There may be a better way to do what you want, but I’ll answer your specific question first.

    Implement public methods in your controller that controls the view that animates off and on again:

    - (void)showInfoView:(MyInfoClass*)theInfo;
    - (void)hideInfoView;
    

    In showInfoView you set a flag that it is shown/showing and animate it on-screen – do this code in a block and call it immediately just to get it working like this…

    dispatch_block_t showBlock = ^
    {
        self.isShowing = YES;
        /* show code goes here */
    };
    showBlock();
    

    In hideInfoView you animate it off and unset the flag in the animation completion block.

    Now in showInfoView before calling that showBlock check the flag to make sure it’s not already shown – if it is then instead of executing the block immediately, add it to the end of an NSMutableArray called toShowBlocks. Then in hideInfoView before unsetting the flag check if the toShowBlocks array is not empty, if it’s not then you remove and call the first item (using the array as a FIFO queue) like this…

    dispatch_block_t nextShowBlock = [toShowBlocks objectAtIndex:0];
    [toShowBlocks removeObjectAtIndex:0];
    nextShowBlock();
    

    Then you simply need to call your show and hide methods as the pins are selected/deselected and this will take care of it for you. This should set you on the right path at least.

    Maybe a better way:

    There are a few problems with the above, the animated view might get hidden and shown a lot if the user goes nuts pressing pins, resulting in a long-winded queue of animations before the user gets the last one. Also, views don’t follow the map around like annotations do when the user pans and zooms the map. So you might be better off using custom annotations for your info view. This is a real pain because MKAnnotation views don’t behave like regular UIViews and this causes all sorts of problems. However, I describe a way to use MKAnnotations as custom call-outs in this answer: https://stackoverflow.com/a/8649951/461492.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a map displaying multiple annotations. I'd like to mimic the behavior of
I have multiple annotations on the map - although the user may need to
Basically: Can my model classes contain @NoBinding annotations with multiple values? If I have
I have multiple forms for lots of products on my page and want to
I have multiple domains on my server. I want to redirect all of them
I'm still learning how to set up these mappings using the JPA annotations so
I am using CraueFormFlowBundle to have a multiple page form, and am trying to
Is it possible to set multiple @Path annotation on the same REST method in
I have A MapView with multiple annotations. I need to put different images to
I have A MapView with Multiple annotations. But I need to put different images

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.