次のクラスを使用して、マップと注釈を含むビューを作成しています。
#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
@interface ContactDetailAnnotation : NSObject <MKAnnotation>
- (id) initWithLatitude:(CLLocationDegrees) lat longitude:(CLLocationDegrees) lng;
- (id) initWithCoordinate:(CLLocationCoordinate2D) coordinateArg;
@property (unsafe_unretained) CLLocationDegrees latitude;
@property (unsafe_unretained) CLLocationDegrees longitude;
@property (unsafe_unretained, nonatomic) CLLocationCoordinate2D coordinate;
@end
問題は、その方法が次のことです。
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
私のポイントを描くために使用されたものはトリガーされていません。私が使用する場合
self.myMap.showsUserLocation = TRUE;
メソッドはトリガーされるので、問題は私が作成したクラスにあるはずです。
私の.m
#import "ContactDetailAnnotation.h"
@implementation ContactDetailAnnotation
@synthesize latitude = _latitude, longitude = _longitude, coordinate = _coordinate;
- (id) initWithCoordinate:(CLLocationCoordinate2D) coordinateArg
{
self.coordinate = coordinateArg;
return self;
}
- (id) initWithLatitude:(CLLocationDegrees)lat longitude:(CLLocationDegrees)lng
{
self.latitude = lat;
self.longitude = lng;
return self;
}
- (CLLocationCoordinate2D) coordinate
{
CLLocationCoordinate2D coord = {self.latitude,
self.longitude};
return coord;
}
@end