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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T06:42:24+00:00 2026-05-21T06:42:24+00:00

I am working on my first app and within it I’m just trying to

  • 0

I am working on my first app and within it I’m just trying to have on button click show a map with a pin (and title on this pin of location). I was able to load the mapview and to have it show the coordinates I want. But when trying to display the pin and annotation I am having issues. Not sure where to code this and how to make annotation to display pin. I’ve searched and seen many tutorials, but most show a different mapview style and are showing pin on user selection, I want to show pin on load of map.

Here is the code I have to show the map which is working, but has no pin display or annotation:

FirstLocateViewController.m code:

#import "FirstLocateViewController.h"

@implementation FirstLocateViewController

@synthesize dismissViewButton;

-(IBAction)dismissView:(id)sender {
[self dismissModalViewControllerAnimated:YES];
}

- (void)viewDidLoad {
[super viewDidLoad];
CGRect frame = CGRectMake(0,0, 320,420);
mapView = [[MKMapView alloc] initWithFrame:frame];
mapView.mapType = MKMapTypeStandard;
CLLocationCoordinate2D coord = {latitude: 12.3456, longitude: -7.890};
MKCoordinateSpan span = {latitudeDelta: 0.05, longitudeDelta: 0.05};
MKCoordinateRegion region = {coord, span};
[mapView setRegion:region];
[self.view addSubview:mapView];

}


FirstLocateViewController.h code:

#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import <MapKit/MKAnnotation.h>


@interface FirstLocateViewController : UIViewController <MKMapViewDelegate> {
UIButton *dismissViewButton;
MKMapView *mapView;
}

@property (nonatomic, retain) IBOutlet UIButton *dismissViewButton;

- (IBAction)dismissViewButton:(id)sender;

@end

Thank you in advanced for any significant 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-05-21T06:42:25+00:00Added an answer on May 21, 2026 at 6:42 am

    For that you need to create annotation create one class which has CLLocationCoordinate2D,title,subtitle like this
    .h file

    #import <Foundation/Foundation.h>
    #import <MapKit/MKAnnotation.h>
    
    
    @interface DisplayMap : NSObject <MKAnnotation> {
    
        CLLocationCoordinate2D coordinate; 
        NSString *title; 
        NSString *subtitle;
    }
    @property (nonatomic, assign) CLLocationCoordinate2D coordinate; 
    @property (nonatomic, copy) NSString *title; 
    @property (nonatomic, copy) NSString *subtitle;
    
    @end
    

    and .m file

    #import "DisplayMap.h"
    
    
    @implementation DisplayMap
    
    @synthesize coordinate,title,subtitle;
    
    
    -(void)dealloc{
        [title release];
        [super dealloc];
    }
    
    @end
    

    and then add following code to viewdidload

    DisplayMap *ann = [[DisplayMap alloc] init]; 
    ann.title=@"put title here";
    ann.coordinate = region.center; 
    [mapView addAnnotation:ann];
    

    and implement following method

    -(MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:
    (id <MKAnnotation>)annotation {
        MKPinAnnotationView *pinView = nil; 
        if(annotation != mapView.userLocation) 
        {
            static NSString *defaultPinID = @"com.invasivecode.pin";
            pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
            if ( pinView == nil ) pinView = [[[MKPinAnnotationView alloc]
                                              initWithAnnotation:annotation reuseIdentifier:defaultPinID] autorelease];
    
            pinView.pinColor = MKPinAnnotationColorPurple; 
            pinView.canShowCallout = YES;
            pinView.animatesDrop = YES;
        } 
        else {
            [mapView.userLocation setTitle:@"I am here"];
        }
        return pinView;
    }
    

    Follow this tutorial:code with explanation is given:

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

Sidebar

Related Questions

Just finished up my first mvc4 app. Everything is working great until I deploy
Suppose I have this simple app working : # model class Project has_many :numbers
I have been trying to parse this ( http://app.calvaryccm.com/mobile/android/v1/devos ) URL using a SAX
I'm working on my first rails app deploy and the database data from my
I'm working on my first major Cocoa app for an undergraduate research project. The
I am working on my first Objective-C app for iOS and am having an
First off, I'm working on an app that's written such that some of your
im working with core-data for the first time, and my app is handling a
I have pretty much finished my first working Symbian application, but in my hastened
I am new to wpf and i am working on first application i have

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.