您的位置:首页 > 产品设计 > UI/UE

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、

tapRecognizer.cancelsTouchesInView = NO;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ios ios 5 ios 6
相关文章推荐