@selector でパラメーターとして渡す必要があるのはなぜですか。カスタム ボタンは、annotationView の一部です。CustomButton では、プロパティ UIButtonType として配置しましたが、出力には何も表示されません。出力は何もないボタンで、View Controller を開きたいときに注釈の内側を修正すると消えます。
これは CustomButton.h のコードです。
@interface CustomButton : UIButton{
}
@property (nonatomic, strong)NSString * name;
@property (nonatomic, assign)UIButtonType typeButton;
@end
CustomButton.m で
@implementation CustomButton.h
@synthesize name;
@synthesize buttonType;
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.typeButton = UIButtonTypeInfoLight;
}
return self;
}
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;
}
注釈の内側をタッチアップすると消えるのはなぜですか?