我有一个带有多个触控手势的框架的第三方视图,我想在顶部添加一个处理单个点击事件的UILabel。出于某种原因,UILabel上的触摸事件在它是第三方视图的子视图时不起作用,但是当我将视图切换到正常的UIView时,它按预期工作。我在这里制作标签:
CGRect frame = CGRectMake(0, 0, 160, 40);
UILabel* label = [[UILabel alloc] initWithFrame:frame];
label.text = [NSString stringWithFormat:@"label"];
label.userInteractionEnabled = YES;
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(labelTapped:)];
singleTap.numberOfTapsRequired = 1;
[label addGestureRecognizer:singleTap];