我对 iOS 开发完全陌生,正在为当地河流创建地图应用程序。该应用程序的重点是允许用户通过选择不同的点来绘制河流上的路线。我正在使用 MapKit 来解决这个问题,但遇到了一些问题。我的主要问题是如何在注释中添加按钮,以便单击后会打开一个详细信息窗口,用户可以了解有关该点的更多信息并将其添加到行程中。这是我的代码,任何想法都会有所帮助!
#import "ViewController.h"
#import "CoreLocation/CLLocation.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.mapView.delegate = self;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
// Add an annotation
MKPointAnnotation *point = [[MKPointAnnotation alloc] init];
point.coordinate = userLocation.coordinate;
point.title = @"Where am I?";
point.subtitle = @"I'm here!!!";
[self.mapView addAnnotation:point];
point.coordinate = CLLocationCoordinate2DMake(33.62258872997,-86.599988937378);
point.title = @"Civitan Park";
point.subtitle = @"Trussville, AL";
[self.mapView addAnnotation:point];
}
@end