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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:48:46+00:00 2026-05-23T17:48:46+00:00

I have a UITableView and each cell contains a Map button. When I tap

  • 0

I have a UITableView and each cell contains a Map button. When I tap each button, Map view is shown and corresponding Annotation pin is added.

This code is called when I tap each map button,

    double tempLatitude  = [[[myDict objectForKey:key] objectAtIndex:15] doubleValue];
    double tempLongitude = [[[myDict objectForKey:key] objectAtIndex:16] doubleValue];
                                                  // key is the cell index.

         //--** Setting the Latitude and Longitude 
         CLLocationCoordinate2D myCoordinate;

         myCoordinate.latitude  = tempLatitude;
         myCoordinate.longitude = tempLongitude;

         MyMapAnnotation *MyAnnotation = [[[MyMapAnnotation alloc] initWithCoordinate:myCoordinate addressDictionary:nil]autorelease];
         MyAnnotation.title            = [[myDict objectForKey:key] objectAtIndex:1];
         MyAnnotation.subtitle         = [NSString  stringWithFormat:@"%f %f", MyAnnotation.coordinate.latitude, MyAnnotation.coordinate.longitude];

And this is the code of MyMapAnnotation,

    @synthesize coordinate = theCoordinate;
    @synthesize title = theTitleAnnotation;
    @synthesize subtitle = theSubTitleAnnotation;



    - (id)initWithCoordinate:(CLLocationCoordinate2D)coordinate addressDictionary:(NSDictionary *)addressDictionary 
    {

      if ((self = [super initWithCoordinate:coordinate addressDictionary:addressDictionary]))
      {
         self.coordinate = coordinate;
      }
         return self;
    }

Everything works fine. Now, when I tap one button, corresponding annotation pin is shown and when I tap second button, the previous pin is still there and second annotation pin is also being added.

But

What I want is,

When I tap each button, the previous annotation pin should be removed and only the current annotation pin should be added.

How can I identify the previous pin?

And where can I give this code [mapView removeAnnotation:annotationToRemove] ??

EDIT: Obviously, the ‘previous annotation pin’ is the ‘annotationToRemove’. I know this. My question is, How can I identify this previous annotation pin to specify as ‘annotationToRemove’??

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-05-23T17:48:47+00:00Added an answer on May 23, 2026 at 5:48 pm

    have you try with [myMap removeAnntoation:[myMap.annotations objectAtIndex:0]]; ?

    EDIT:
    There are several ways to do this, one is to set a tag to the annotation, then search it by tag; another way is to check all annotations and then remove that which you want, if your problem is to remove the previous annotation added, you can call:

    [myMap removeAnntoation:[myMap.annotations lastObject]];

    P.S: if you have myMap.showsUserLocation=YES; look this: How to remove all annotations from MKMapView without removing the blue dot?.

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

Sidebar

Related Questions

I have a UITableView with 5 UITableViewCells . Each cell contains a UIButton which
I have a UITableView that contains a UITextField in each cell. I can't seem
I have a UITableView with custom background images in each cell. The bottom cell
I have a UITableView cell that is going to have a variable size depending
I have an app that has a tab bar, each tab contains a separate
I have got an UITableView. How to simply fill it with three elements, for
I have a need to display a UITableView containing a user's account credentials. For
I have a UIView with a UITableView for a subview. The UIView has an
I have an array of objects which populate a UITableView . When a user
In an app I'm working on, I have a plain style UITableView that can

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.