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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:02:57+00:00 2026-06-11T10:02:57+00:00

trying to figure out if it is possible when a button is pressed to

  • 0

trying to figure out if it is possible when a button is pressed to go to a certain longitude and latitude in mapView and drop a button. I copied my code for a “newAnnotation” pin which previously worked, but realize now it might not be working inside of the code of my button. Here is my button code:

-(IBAction)buttonPressed 
{
CLLocationCoordinate2D location;
MKCoordinateSpan span;
location.latitude = (double) 44.4758;
    location.longitude = (double) -73.2125;
span.latitudeDelta=0.2;
span.longitudeDelta=0.2;


    MapViewAnnotation *newAnnotation = [[MapViewAnnotation alloc] initWithTitle:@"BCA" 
    andCoordinate:location];
[self.mapView addAnnotation:newAnnotation];
[newAnnotation release];


themapView = [[MapView alloc] initWithNibName:@"MapView" bundle:nil];
[self.view addSubview:themapView.view]; 
}

I know that the button WORKS and that it actually goes to the mapView and is processing the coordinates, but that it just isn’t dropping the pin with the title. Currently there are no errors as my code stands. If you need to see other code, let me know. Thanks a million.

  • 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-11T10:02:58+00:00Added an answer on June 11, 2026 at 10:02 am

    I think your problem is that you are adding an annotation to a map view that is not visible yet. You have to first add the map view view as a subview then add the annotation. Here is what the code would look like:

    -(IBAction)buttonPressed 
    {
    CLLocationCoordinate2D location;
    MKCoordinateSpan span;
    location.latitude = (double) 44.4758;
        location.longitude = (double) -73.2125;
    span.latitudeDelta=0.2;
    span.longitudeDelta=0.2;
    
    MapViewAnnotation *newAnnotation = [[MapViewAnnotation alloc] initWithTitle:@"BCA" 
    andCoordinate:location];
    [self.mapView addAnnotation:newAnnotation];
    [newAnnotation release];
    
    
    themapView = [[MapView alloc] initWithNibName:@"MapView" bundle:nil];
    [self.view addSubview:themapView.view]; 
    
    }
    

    UPDATE:

    Can we see the code for MapViewAnnotation. It should be an NSObject class which adopts MKAnnotation like this <MKAnnotation> and you should declare and synthesize three properties: title, subtitle if you like, and of course coordinate

    Another problem may be that you are adding MapView‘s view as a subview. It might be better to put this code in MapView and present MapView as a view controller

    I also do not understand why you are adding an annotation to self.mapView and then adding a subview over it…..

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

Sidebar

Related Questions

I'm trying to figure out if its possible to stop a foreach loop in
I'm trying to figure out if this is possible. I have a class, BaseGameEntity,
I was trying to figure out if it was possible to pass in a
In the course of trying to figure out whether it's possible to contain text
Possible Duplicate: Regex question mark I am trying to figure out how to parse
Hey, I'm trying to figure out if it's possible to overload a template class
Specifically, I'm trying to figure out if it's possible to generate SQL that does
I'm trying to learn and figure out if it is possible to deploy an
I am trying to figure out to change the follow code to a Lambda
I'm trying to figure out how many possible ways there are to combine various

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.