NSMutableArray* annotations = [[NSMutableArray alloc] init];
//This is the details needed to make a new annotation.
CLLocationCoordinate2D autoCoord1;
autoCoord1.latitude = 37.78616;
autoCoord1.longitude = -122.41018;
MyAnnotation* autoAnnot1 = [[MyAnnotation alloc] init];
autoAnnot1.coordinate = autoCoord1;
autoAnnot1.title = @"auto";
autoAnnot1.subtitle = @"auto";
[mapViewVC addAnnotation:autoAnnot1];
[annotations addObject:autoAnnot1];
我有这段代码在我的另一个 mapkit 应用程序中工作,但是我似乎无法autoAnnot1
在给定坐标的地图上看到注释。
当然,代码[mapViewVC addAnnotation:autoAnnot1];
应该将该注释添加到地图中?
MyAnnotation.h 类如下所示:
#import <Foundation/Foundation.h>
#import "MapKit/MapKit.h"
@interface MyAnnotation : NSObject <MKAnnotation> {
CLLocationCoordinate2D coordinate;
NSString* title;
NSString* subtitle;
}
@property (nonatomic, assign) CLLocationCoordinate2D coordinate;
@property (nonatomic, copy) NSString* title;
@property (nonatomic, copy) NSString* subtitle;
@end
下面是显示断点和输出的图像