I'm創建與地圖,並使用以下類的註釋的圖:MKAnnotation doesn't觸發銷點引法
#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;
的方法trigered,所以問題必須是在我創建的類。
我的.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
應該不需要重載' - (CLLocationCoordinate2D)座標方法。 – 2012-04-16 20:21:08
如果它刪除該方法,它會崩潰。 – bruno 2012-04-16 21:41:58