点击按钮时取消UIGestureRecognizer?

时间:2013-04-19 07:33:14

标签: ios objective-c ios5 uigesturerecognizer

点击按钮时是否可以取消UIGestureRecognizer

3 个答案:

答案 0 :(得分:8)

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
    // test if our control subview is on-screen
    if([gestureRecognizer isMemberOfClass:[UITapGestureRecognizer class]]){
        if ([touch.view isKindOfClass:[UIButton class]]) {
            return NO; // ignore the touch
        }
    }
    return YES; // handle the touch
}

答案 1 :(得分:0)

试试这个方法:

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{

return whateverYouWant;
} 

答案 2 :(得分:0)

是的,你可以。您可以通过此代码添加和删除。

-(IBAction) YourButtonAction {
  some code, that your button must to do
  self.yourButton removeGestureRecognizer: (yourRecognizer);
}