在view上加了UITapGestureRecognizer之后,这个view上的所有触摸事件都被UITapGestureRecognizer给吸收了,所以要解决这个bug,要给这个手势代理加一些事件过滤,对button事件就不要拦截独吞了。代码如下:
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(cilck)];
tapGesture.delegate = self;
[friendView addGestureRecognizer:tapGesture];
pragma mark UIGestureRecognizerDelegate
-
(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
if ([touch.view isKindOfClass:[UIButton class]]) {
//放过button点击拦截
return NO;
}else{
return YES;
}
}