UITapGestureRecognizerとUIButtonを使用してiPhoneアプリケーションで作業しています。self.viewにUITapGestureRecognizerを追加しました。UIButtonをクリックしても、そのアクションは呼び出されません。タプジェスチャアクションのみが呼び出されます。この問題を解決する方法は?誰かがこの問題を解決するのを手伝ってもらえますか?
これが私のコードです-ViewDidLoad
、
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapFrom:)];
[self.view addGestureRecognizer:tapRecognizer];
[tapRecognizer release];
UIButton *infoButton1 = [UIButton buttonWithType:UIButtonTypeInfoDark];
infoButton1.frame = CGRectMake(0, 5, 30, 30);
infoButton1.tag = 1;
infoButton1.opaque = YES;
[infoButton1 addTarget:self action:@selector(infoAlert:) forControlEvents:UIControlEventTouchUpInside | UIControlEventTouchUpOutside];
[toolBarView1 addSubview:infoButton1];
-(void) infoAlert:(id) sender
{
NSLog(@"Get Info Alert"); // Here the control not calling..
}
-(void)handleTapFrom:(UITapGestureRecognizer *)recognizer
{
NSLog(@"%@",[NSString stringWithFormat:@"%d", recognizer.view.tag]); // Whenever i touch the button this method only calling.
}
この問題を解決するのを手伝ってください。前もって感謝します。