ラベルを作成してタップ ジェスチャを設定しましたが、タップするとエラーが表示されます。
私のコードは.hファイルです
@interface ViewController : UIViewController
{
UILabel *alabel;
}
@property (strong, nonatomic) UILabel *alabel;
.m ファイルで
- (void)viewDidLoad
{
[super viewDidLoad];
alabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 100, 50)];
alabel.text = @"Drag me!";
alabel.userInteractionEnabled = YES;
UITapGestureRecognizer *tapGesture =[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(labelTap)];
[alabel addGestureRecognizer:tapGesture];
[self.view addSubview:alabel];
}
- (void)labelTap:(UITapGestureRecognizer *)tapGesture {
TouchLabelViewController *touchLabelViewController = [[TouchLabelViewController alloc] initWithNibName:@"TouchLabelViewController" bundle:[NSBundle mainBundle]];
[self presentModalViewController:touchLabelViewController animated:NO];
}
ログ表示
2012-10-29 11:19:17.313 DragableControll[795:f803] -[ViewController labelTap]: unrecognized selector sent to instance 0x68956b0
2012-10-29 11:19:17.316 DragableControll[795:f803] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ViewController labelTap]: unrecognized selector sent to instance 0x68956b0'