所以我已经实现了我的 viewForAnnotation
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {
static NSString *identifier = @"id";
if ([annotation isKindOfClass:[infl8Node class]]) {
NSLog(@"Creating a pin");
MKPinAnnotationView *annotationView = (MKPinAnnotationView *) [_mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
if (annotationView == nil) {
annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
} else {
annotationView.annotation = annotation;
}
annotationView.enabled = YES;
annotationView.canShowCallout = YES;
return annotationView;
}
return nil;
}
但是我仍然遇到这个错误:
2012-11-18 22:12:35.608 Infl8[5960:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[infl8Node coordinate]: unrecognized selector sent to instance 0x846f460'
有谁知道可能导致此错误的原因?我已经将其追溯到注释属于 MKUserLocation 类的情况。
编辑:这是 infl8Node.h 文件:
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
#import <MapKit/MapKit.h>
@interface infl8Node : NSObject <MKAnnotation>
@property (nonatomic, strong) NSString *accountName;
@property (nonatomic, strong) NSString *status;
@property (nonatomic, strong) CLLocation *location;
@property (nonatomic, strong) NSDictionary *address;
- (id) initWithDictionary:(NSDictionary *)dict;
- (MKMapItem *) mapItem;
@end