参考
http://studio.tgl.jp/blog/?p=1840
http://qiita.com/AKIHIRO_ciil/items/efb37f2aaa2136d7cca7
概要
UIGestureRecognizerとUIButton(など)を一緒に配置するとUIButtonが反応しない。
その場合、どうすればいいのか?
対応策
UIGestureRecognizerのcancelsTouchesInViewをNOにする。
header
@interface ViewController : UIViewController <UIGestureRecognizerDelegate>
- (void)viewDidLoad {
[super viewDidLoad];
UIGestureRecognizer* gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)];
gesture.cancelsTouchesInView = NO; // この設定が必要
gesture.delegate = self;
[self.view addGestureRecognizer:gesture];
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
if(gestureRecognizer.view == touch.view){
return YES;
}else{
return NO;
}
}