UIButton如果触摸的视图属于某些类(即and ) ,我会尝试忽略我的gestureRecognizer UIBarButtonItem:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
NSLog(@"%@", touch.view);
if ([touch.view isKindOfClass:[UIButton class]]){
return NO;
} else if ([touch.view isKindOfClass:[UIBarButtonItem class]]){
return NO;
}
return YES; // handle the touch
}
这对UIButton. 它不适用于UIBarButtonItem. 触摸时我的 NSLog 结果UIBarButtonItem是:
<UIToolbarTextButton: 0x7b8f500; frame = (4 0; 60 40); opaque = NO; layer = <CALayer: 0x7b8f900>> 2012-06-26 12:09:48.021
我已经尝试将 更改[UIBarButtonItem class]为[UIToolBarTextButton class],但由于这是一个无证类,我不能这样做。还有其他方法可以做到这一点吗?
谢谢。