点击按钮时是否可以取消UIGestureRecognizer
?
答案 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);
}