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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:11:40+00:00 2026-05-22T18:11:40+00:00

When I drop a pin on my mkmapview the animation works fine and the

  • 0

When I drop a pin on my mkmapview the animation works fine and the pin drops from the top of the screen as expected. I color that pin red because I haven’t verified it. However, if I verify the pin using some code that is called on calloutAccessoryControlTapped I change the color of the Pin to green.

When I next press on the map to drop another red pin the animation fails and the pin just appears. If I do it again (long press) a new pin appears and it’s animation is fine. What could I have done to the annotation that causes this behavior.

Thanks for any insights of what could have gone wrong here…
Donie

- (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation 
{

    if ([annotation isKindOfClass:[MKUserLocation class]]) 
    {
        return nil;     
    }

    static NSString * const kPinIdentifier = @"PinIdentifier";
    MKPinAnnotationView *draggablePinView = (MKPinAnnotationView *)[self.mapView dequeueReusableAnnotationViewWithIdentifier:kPinIdentifier];

    if(!draggablePinView)
    {
        draggablePinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:kPinIdentifier] autorelease];
        draggablePinView.pinColor = MKPinAnnotationColorRed;
        draggablePinView.animatesDrop = YES;
        draggablePinView.canShowCallout = YES;
        draggablePinView.draggable = YES;


        UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        draggablePinView.rightCalloutAccessoryView = rightButton;
    }
    else
    {
        draggablePinView.annotation = annotation;
        draggablePinView.animatesDrop = YES;
    }
    return draggablePinView;
}


-(void)longPressGesture:(UIGestureRecognizer *)gestureRecognizer
{    
    if (gestureRecognizer.state == UIGestureRecognizerStateBegan)
    {
        CGPoint touchPoint = [gestureRecognizer locationInView:mapView];
        CLLocationCoordinate2D touchMapCoordinate = [mapView convertPoint:touchPoint toCoordinateFromView:mapView];

        [self dropPinWithCoords:touchMapCoordinate];
    }
}

- (void)mapView:(MKMapView *)mapview annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{        
    [self getFromServer];
}

-(void) showLoc8CodeDetail:(LOC8Code *) loc8
{
    // Open the view controller
    viewLoc8ViewController *loc8view = [[viewLoc8ViewController alloc] initWithLoc8code:loc8];
    [gMainViewController.navigationController pushViewController:loc8view animated:YES];
    [loc8view release];
}

-(void) dropPinWithCoords:(CLLocationCoordinate2D)loc
{
    // Set the loc8code from index 0 in the global array and populate from response
    LOC8Code *newPin = [gMapAnnotations objectAtIndex:0];
    newPin.starRating = 1;
    newPin.title = @"Unverified Pin";
    newPin.subtitle = @"Click to verify postcode";
    newPin.verified = NO; // this means you do have to requery if opened
    newPin.coordinate = loc;


    [self removeMapAnnotations];        
    [gMapAnnotations replaceObjectAtIndex:1 withObject:newPin];
    [self.mapView addAnnotation:[gMapAnnotations objectAtIndex:1]];

    // Reset flags
    [dropPinButton setTitle:@"Replace Pin" forState:UIControlStateNormal];
    [self moveAndHidePinButtons:NO];
}
-(void)getFromServer
{
    [self checkRegisteredFromServer]; // Does API call to see if device already registered

    // Get the loc8 code from the global array (pin always index 1)
    LOC8Code *loc8 = [gMapAnnotations objectAtIndex:1];

    // If we have a verified pin already (from a search) just show the info
    if(loc8.verified == YES)
    {
        [self showLoc8CodeDetail:loc8];
    }
    else
    {
        [self setSpinning:YES];
        // Get coordinates
        NSString *urlWithCoords = [NSString stringWithFormat:@"https://www.server.com/api/rest/lite/loc?t=%@&u=%@&a=iloc8er&la=%f&lo=%f", 
                                    [Util getAPIToken], [UIDevice currentDevice].uniqueIdentifier, 
                                    loc8.coordinate.latitude,
                                    loc8.coordinate.longitude];
        NSLog(@"%@", urlWithCoords);
        ASIHTTPRequest *request = [self populateRequest:request withURL: urlWithCoords];
        [request setDidFinishSelector:@selector(loc8returned:)];
        [[self networkQueue] addOperation:request]; 
    }
}

-(void)loc8returned:(ASIHTTPRequest *)request
{
    @try 
    {    
        NSString *response = [request responseString];
        NSLog(@"RSP: %@", response);

        // Store incoming data into an NSDictionary
        SBJsonParser *parser = [[SBJsonParser new]autorelease];
        NSDictionary *results = [parser objectWithString:response error:nil];

        // Check for errors
        NSNumber *r = [results objectForKey:@"r"];
        NSString *e = [results valueForKey:@"e"];

        if(r.boolValue == NO)
        {
            if([e isEqualToString:@"lc51"] || [e isEqualToString:@"lc52"])
            {
                // Outside range
                [self setSpinning:NO];
                return;
            }

            if([e isEqualToString:@"ud04"])
            {
                // quota check
                [self setSpinning:NO];
                return;
            }
        }
        else
        {
            LOC8Code *loc8 = [gMapAnnotations objectAtIndex:1];

            // Set the loc8code
            NSString *lc = [results valueForKey:@"lc"];
            loc8.postcode = lc;
            loc8.verified = YES;
            loc8.starRating = 0;
            loc8.title = lc;


            // This pin is now validated
            MKPinAnnotationView *pinView = (MKPinAnnotationView*)[mapView viewForAnnotation:[gMapAnnotations objectAtIndex:1]];
            pinView.pinColor = MKPinAnnotationColorGreen;

            // Open the view controller
            [self showLoc8CodeDetail:loc8];
        }
    }
    @catch (NSException *exception) 
    {
        [Util say:@"Service Temporarily Unavailable (-200):"];
        NSLog(@"RSP: %@, %@", [exception name], [exception reason]);
    }
    [self setSpinning:NO];
}

The loc8code header class is defined as follows:

@interface LOC8Code : MKPlacemark {
    NSString *postcode;
    NSString *BusinessName;
    int starRating;
    CLLocationCoordinate2D coordinate_;
    NSString *title_;
    NSString *subtitle_;
    BOOL verified;          // Verified locations can't be moved (if pin moved then flag as not verified)
}

// Re-declare MKAnnotation's readonly property 'coordinate' to readwrite. 

@property (nonatomic, retain) NSString *postcode;
@property (nonatomic, retain) NSString *BusinessName;
@property (nonatomic, assign) int starRating;
@property (nonatomic, readwrite, assign) CLLocationCoordinate2D coordinate;
@property (nonatomic, retain) NSString *title;
@property (nonatomic, retain) NSString *subtitle;
@property (nonatomic, assign) BOOL verified;

@end

And the implementation

#import "LOC8Code.h"

@implementation LOC8Code

@synthesize coordinate = coordinate_;
@synthesize title = title_;
@synthesize subtitle = subtitle_;
@synthesize verified;
@synthesize starRating;
@synthesize postcode;
@synthesize BusinessName;


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

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

- (void)dealloc {
    [title_ release];
    [subtitle_ release];
    [postcode release];
    [BusinessName release];

    [super dealloc];
}

@end
  • 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-22T18:11:41+00:00Added an answer on May 22, 2026 at 6:11 pm

    It’s probably due to the fact you’re using the same reuse identifier all the time. Check out this line: static NSString * const kPinIdentifier = @"PinIdentifier";

    That value needs to be unique for each pin you drop if all these pins are going to be different. I often use a comma-separated string of the latitude and longitude of a marker for my identifiers.

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

Sidebar

Related Questions

I drop a pin in an MKMapView with longitude and latitude. When I place
when i try to download a image from my iPhone (Drop Pin Marker) through
I'm confused on how this works. I'm creating a CLGeocoder to drop a pin
I readed this: Drop Pin on Default Google Maps from My App in Android?
I have a function that drop pin with this code: ParkPlaceMark *placemark=[[ParkPlaceMark alloc] initWithCoordinate:location];
I have a button that creates a new drop pin. That pin is in
I have an MKMapView and another UIView subclass that is overlaid on top of
DROP TABLE ( SELECT table_name FROM information_schema.`TABLES` WHERE table_schema = 'myDatabase' AND table_name LIKE
I created a PHP Drop Down which is populated from a MySql Database and
I want to drop some data from treeview to the datagridview temporarily, but the

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.