注釈を管理しようとしています。PINが選択されたときにビューの右側に情報ボタンを表示するには、関連するコードは次のとおりです。
- (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation {
MKPinAnnotationView *newAnnotation = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"greenPin"];
if ([annotation isKindOfClass:[ManageAnnotations class]]) {
static NSString* identifier = @"ManageAnnotations";
MKPinAnnotationView *newAnnotation = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
if (newAnnotation==nil) {
newAnnotation=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
}else {
newAnnotation.annotation=annotation;
}
newAnnotation.pinColor = MKPinAnnotationColorGreen;
newAnnotation.animatesDrop = YES;
newAnnotation.canShowCallout = YES;
newAnnotation.rightCalloutAccessoryView=[UIButton buttonWithType:UIButtonTypeInfoLight];
return newAnnotation;
}else {
newAnnotation.pinColor = MKPinAnnotationColorGreen;
newAnnotation.animatesDrop = YES;
newAnnotation.canShowCallout = YES;
return newAnnotation;
}
ManageAnnotations.m:
@implementation ManageAnnotations
@synthesize pinColor;
@synthesize storeName=_storeName;
@synthesize storeAdress=_storeAdress;
@synthesize coordinate=_coordinate;
-(id)initWithTitle:(NSString*)storeName adress:(NSString*)storeAdress coordinate:(CLLocationCoordinate2D)coordinate{
if((self=[super init])){
_storeName=[storeName copy];
_storeAdress=[storeAdress copy];
_coordinate=coordinate;
}
return self;
}
-(NSString*)title{
return _storeName;
}
-(NSString*)subtitle{
return _storeAdress;
}
ManageAnnotations.h
@interface ManageAnnotations : NSObject<MKAnnotation>{
NSString *_storeName;
NSString *_storeAdress;
CLLocationCoordinate2D _coordinate;
}
//
@property(nonatomic,assign)MKPinAnnotationColor pinColor;
@property(nonatomic, readonly, copy)NSString *storeName;
@property(nonatomic, readonly, copy)NSString *storeAdress;
@property(nonatomic,readonly)CLLocationCoordinate2D coordinate;
//
-(id)initWithTitle:(NSString*)storeName adress:(NSString*)storeAdress coordinate:(CLLocationCoordinate2D)coordinate;
//
PINはマップ上に正しく表示されますが、ビューの右側に情報ボタンはありません。私は何かが足りないのですか?