UIButton inside a view that has a UITapGestureRecognizer
2013-08-27 18:23
453 查看
在ios 5.0 如果在视图A上加一个手势,然后加一个UIButton B,但是我发现 点击按钮的时候是没有反应的,有时候点击按钮然后拽动可以有反应。
但是在ios 6.0 没有出现这样的问题。
我们可以这样:
1、
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
// test if our control subview is on-screen
if (self.controlSubview.superview != nil) {
if ([touch.view isDescendantOfView:self.controlSubview]) {
// we touched our control surface
return NO; // ignore the touch
}
}
/*
if ([touch.view isKindOfClass:[UIButton class]]){
return NO;
}
*/
return YES; // handle the touch
}
2、
但是在ios 6.0 没有出现这样的问题。
我们可以这样:
1、
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
// test if our control subview is on-screen
if (self.controlSubview.superview != nil) {
if ([touch.view isDescendantOfView:self.controlSubview]) {
// we touched our control surface
return NO; // ignore the touch
}
}
/*
if ([touch.view isKindOfClass:[UIButton class]]){
return NO;
}
*/
return YES; // handle the touch
}
2、
tapRecognizer.cancelsTouchesInView = NO;
相关文章推荐
- 如何解决UIScrollView中添加UITapGestureRecognizer跟UIButton点击事件冲突
- 如何解决UIScrollView中添加UITapGestureRecognizer跟UIButton点击事
- iOS UITapGestureRecognizer手势和UIButton 以及UITabelView点击事件冲突
- iOS中添加UITapGestureRecognizer手势识别后,UITableView的didSelectRowAtIndexPath失效
- iOS中添加UITapGestureRecognizer手势识别后,UITableView的didSelectRowAtIndexPath失效
- iOS中添加UITapGestureRecognizer手势识别后,UITableView的didSelectRowAtIndexPath失效 或者点击UITableView的空白处收起键盘
- iOS 6.0之前 UITapGestureRecognizer手势和UIButton 点击事件冲突
- 解决UITapGestureRecognizer手势与UITableView的点击事件的冲突
- 添加UITapGestureRecognizer手势识别后,UITableView的didSelectRowAtIndexPath失效
- 在已经响应UITapGestureRecognizer的UIView中清晰的响应UIButton点击事件
- iOS中添加UITapGestureRecognizer手势识别后,UITableView的didSelectRowAtIndexPath失效
- UITapGestureRecognizer 与 UIButton 按钮 无响应的bug
- iOS中添加UITapGestureRecognizer手势识别后,UITableView的didSelectRowAtIndexPath失效
- UITapGestureRecognizer手势与UITableView冲突解决
- UITapGestureRecognizer和UIButton的点击事件冲突的解决办法
- iOS中添加UITapGestureRecognizer手势识别后,UITableView的didSelectRowAtIndexPath失效
- iOS中添加UITapGestureRecognizer手势识别后,UITableView的didSelectRowAtIndexPath失效
- iOS中添加UITapGestureRecognizer手势识别后,UITableView的didSelectRowAtIndexPath失效
- iOS中添加UITapGestureRecognizer手势识别后,UITableView的didSelectRowAtIndexPath失效
- iOS中添加UITapGestureRecognizer手势识别后,UITableView的didSelectRowAtIndexPath失效