I am working on my first application, and in it I just try to click on the mouse button to show the map with a pin (and the name on this location pin). I was able to load mapview and show which coordinates I want. But when I try to display the output and annotation, I have problems. Not sure where to encode this and how to make annotations to display the output. I searched and saw a lot of tutorials, but most of them demonstrate a different style of mapview and show the output of the user's choice, I want to show the output when loading the map.
Here is the code that I have to show on a map that works, but does not display output or annotation:
Code FirstLocateViewController.m:
#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];
}
Code FirstLocateViewController.h:
#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 for your advanced support.
474N
source share