问题描述:
1.view上添加了一个UITapGestureRecognizer
2.view上添加了一个button
3.在iOS 6.0+上测试一切正常,在ios5.0(5.1)上UIButton只能点击但是就是不进入target事件之中
设置手势的代理:
tapGesture.delegate = self;
最后实现代理里面这个方法:
// called before touchesBegan:withEvent: is called on the gesture recognizer for a new touch. return NO to prevent the gesture recognizer from seeing this touch
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
// 过滤掉UIButton,也可以是其他类型
if ( [touch.view isKindOfClass:[UIButton class]])
{
return NO;
}
return YES;
}