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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:13:20+00:00 2026-06-13T15:13:20+00:00

In my app, I have a mapView that drops a pin with a UILongPressGestureRecognizer.

  • 0

In my app, I have a mapView that drops a pin with a UILongPressGestureRecognizer. When the screen is pressed, the coordinate is geocoded and a pin is dropped, and the address is set as the title. There will be multiple pins on the screen, and the annotation view has a callout accessory that pushes another controller, called the PinViewController onto the stack. The PinViewController has a label, which I want to show the title of the pin.

Here is the code for dropping the pin:

-(void)press:(UILongPressGestureRecognizer *)recognizer
{
    CGPoint touchPoint = [recognizer locationInView:worldView];
    CLLocationCoordinate2D touchMapCoordinate = [worldView convertPoint:touchPoint toCoordinateFromView:worldView];

    geocoder = [[CLGeocoder alloc]init];
    CLLocation *location = [[CLLocation alloc]initWithCoordinate:touchMapCoordinate
                                                    altitude:CLLocationDistanceMax
                                          horizontalAccuracy:kCLLocationAccuracyBest
                                            verticalAccuracy:kCLLocationAccuracyBest
                                                   timestamp:[NSDate date]];
    [geocoder reverseGeocodeLocation:location
               completionHandler:^(NSArray *placemarks, NSError *error) {
                   NSLog(@"reverseGeocoder:completionHandler: called");
                   if (error) {
                       NSLog(@"Geocoder failed with error: %@", error);
                   } else {
                       CLPlacemark *place = [placemarks objectAtIndex:0];
                       geocodedAddress = [NSString stringWithFormat:@"%@ %@, %@ %@", [place subThoroughfare], [place thoroughfare], [place locality], [place administrativeArea]];

                       if (UIGestureRecognizerStateBegan == [recognizer state]) {
                           addressPin = [[MapPoint alloc]initWithAddress:geocodedAddress coordinate:touchMapCoordinate
                                                                   title:geocodedAddress];
                           [worldView addAnnotation:addressPin];
                       }
                   }
               }];
}

And here is the code where the PinViewController is pushed to the stack:

-(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
    PinViewController *pinViewController = [[PinViewController alloc]init];
    [[self navigationController]pushViewController:pinViewController animated:YES];
    pinViewController.label.text = addressPin.title;
}

The trouble I am having is that the label is only showing the last address to be geocoded. So when I drop the a pin and press the callout accessory button, the correct address is pushed to the PinViewController. But if I press the callout accessory button of another annotation, the address of the last pin dropped is pushed to the PinViewController. So I need to find a way so that when I press the callout accessory button of a annotation view, the title of the annotation is passed to the PinViewController. I would really appreciate some help.

  • 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-13T15:13:21+00:00Added an answer on June 13, 2026 at 3:13 pm

    Your issue is that you are using addressPin which is always going to be the last pin that was geocoded. You need to use the annotationView to access the annotation that was pressed.

    -(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
    {
        PinViewController *pinViewController = [[PinViewController alloc]init];
        [[self navigationController]pushViewController:pinViewController animated:YES];
        pinViewController.label.text = view.annotation.title;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing on an app that is location-based, I have a mapView set to
I have an app that has a mapview, and it shows 20 pins (from
My app have a background image that fills the screen. I'd like to display
I have a small app that from the home screen has a few buttons,
I have custom annotation pin at app: - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
I have an Android app that when launched, inflates a MapView, gets the user's
I am building a Tab Bar App and have a MapView set up on
I have an app, that uses mapview. i can only see the map, when
Imagine that I have a camera app where I show a small MapView in
I have a little app that have by default youtube as homepage. You 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.