I created a CustomButton why do I need to pass as parameter in a @selector. The custom button is part of a annotationView. In CustomButton I put as property UIButtonType, but in the output nothing comes out. The output is a button with nothing, and when I get to touch up inside the annotation disappear while I want to open a view controller.
This is the code in CustomButton.h
@interface CustomButton : UIButton{
}
@property (nonatomic, strong)NSString * name;
@property (nonatomic, assign)UIButtonType typeButton;
@end
in CustomButton.m
@implementation CustomButton.h
@synthesize name;
@synthesize buttonType;
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.typeButton = UIButtonTypeInfoLight;
}
return self;
}
in MapViewController.m
-(void)loadDetailListViewController: (CustomButton *)aName{
//I want to open a viewController
//.......
}
- (MKAnnotationView *)mapView:(MKMapView *)mapview viewForAnnotation:(id
<MKAnnotation>)annotation
{
//.......
MKPinAnnotationView *annotationView = (MKPinAnnotationView*) [mapView
dequeueReusableAnnotationViewWithIdentifier:AnnotationIdentifier];
annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation
reuseIdentifier:AnnotationIdentifier];
//.........
CustomButton *rightButton = [CustomButton buttonWithType:UIButtonTypeCustom];
[rightButton setName:[NSString stringWithFormat:@"%@", self.nameTable]];
[rightButton addTarget:self action: @selector(loadDetailListViewController:)
forControlEvents:UIControlEventTouchUpInside];
annotationView.rightCalloutAccessoryView = rightButton;
annotationView.canShowCallout = YES;
annotationView.draggable = YES;
return annotationView;
}
Why when I touch up inside the annotation disappear?