`
ydbc
  • 浏览: 719084 次
  • 性别: Icon_minigender_1
  • 来自: 大连
文章分类
社区版块
存档分类
最新评论

UIButton inside a view that has a UITapGestureRecognizer

 
阅读更多

在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;

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics