[英]How to pass touch event frome a UIScrollView's subview to it's superview
我在窗户上有三个景色。 UIView包含UIScrollView,UIScrollView包含UILabel。所有这些视图均为320 * 460。 现在,我想处理UILabel上的长按事件,并将tap事件传递给UIView。 我重写了标签的touchesEnded:以获取新闻发布时间。 如果时间足够短,我可以使用[[self nextResponder] touchesBegan:touches withEvent:event]来传递时间。 但是,即使我重写UIScrollview并向其添加[[self nextResponder] touchesBegan:touches withEvent:event],UIView也无法接收touchesBegan事件。 而且,如果我为UIScrollView设置userInteractionEnabled = NO,则UIView会得到touchedBegan,而UILabel无法接收它。
我如何才能首先在UILabel中获取touch事件并将其传递给UIView(如果需要)。
谢谢。
尝试使用UITapGestureRecognizer来检测UIScrollView中的事件
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTapGestureCaptured:)];
[scrollView addGestureRecognizer:singleTap];
您将得到以下方面的信息:
- (void)singleTapGestureCaptured:(UITapGestureRecognizer *)gesture
{
CGPoint touchPoint=[gesture locationInView:scrollView];
}
我是这样理解你的问题的。
您有UIView和UILabel之间的scrollview。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.