The rightCalloutAccessory button is not shown

Posted by Luca on Stack Overflow See other posts from Stack Overflow or by Luca
Published on 2012-06-17T07:55:01Z Indexed on 2012/06/17 15:16 UTC
Read the original article Hit count: 318

I try to manage annotations, and to display an info button on the right of the view when a PIN get selected, my relevant code is this:

- (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;
//

The PINS are shown correctly on the Map, but without the info button on the right of the view. Am i missing something?

© Stack Overflow or respective owner

Related posts about ios5

Related posts about mkmapview