我有一个看起来像这样的视图层次结构:
UIView (A)
UIView > UIImageView
UIView > UIView (B)
UIView > UIView (B) > Rounded Rect Button
UIView > UIView (B) > UIImageView
UIView > UIView (B) > UILabel
Run Code Online (Sandbox Code Playgroud)
我已将手势识别器附加到我的UIView(B).我面临的问题是我没有对UIView(B)中的Rounded Rect Button进行任何操作.singleTap手势识别器捕获/覆盖按钮的Touch Up Inside事件.
我怎样才能使它工作?我认为响应者链层次结构将确保按钮触摸事件将被优先使用,并且它将被触发!我错过了什么?
这是一些相关的代码:
#pragma mark -
#pragma mark View lifecycle (Gesture recognizer setup)
- (void)viewDidLoad {
[super viewDidLoad];
// double tap gesture recognizer
UITapGestureRecognizer *dtapGestureRecognize = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doubleTapGestureRecognizer:)];
dtapGestureRecognize.delegate = self;
dtapGestureRecognize.numberOfTapsRequired = 2;
[self.viewB addGestureRecognizer:dtapGestureRecognize];
// single tap gesture recognizer
UITapGestureRecognizer *tapGestureRecognize = …Run Code Online (Sandbox Code Playgroud)