I am using below code for add button in mapView but button click event is working on only left size it's not working on right side.
MKPinAnnotationView *pinAnnotation = nil;
if(annotation != beerMapView.userLocation)
{
static NSString *defaultPinID = @"myPin";
pinAnnotation.pinColor = MKPinAnnotationColorRed;
pinAnnotation = (MKPinAnnotationView *)[beerMapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
if ( pinAnnotation == nil )
pinAnnotation = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:defaultPinID] autorelease];
NSLog(@"PinAnnotation: %@",NSStringFromCGRect(pinAnnotation.frame));
pinAnnotation.canShowCallout = YES;
pinAnnotation.image = [UIImage imageNamed:@""]; //Set blank pin image
UIImageView *pinImage = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 40, 40)];
pinImage.image = [UIImage imageNamed:@"ic_pin.png"];
UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[infoButton setImage:[UIImage imageNamed:@"ic_pin.png"] forState:UIControlStateNormal];
infoButton.frame = CGRectMake(0, 0, 40, 40);
pinAnnotation.rightCalloutAccessoryView = infoButton;
[infoButton addTarget:self action:@selector(detailBtnClk:) forControlEvents:UIControlEventTouchUpInside];
[pinAnnotation addSubview:infoButton];
}
infoButton - > left portion(0 to 20) button click event working. (Call detailBtnClk)
infoButton - > right portion(21 to 40) button click event is not working. (Can not call detailBtnClk)
Any help is appreciated.