如何将触摸事件传递给tableview下的另一个视图? [英] How to pass touch event to another view under tableview?

查看:57
本文介绍了如何将触摸事件传递给tableview下的另一个视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一种情况,我将视图(视图内的 pageViewController )与偏移量为130的 uitableview 重叠,并且将 uitableview 是透明的,只有单元格将滚动并可见.

I have a scenario where I overlapped a view(pageViewController inside the view) with a uitableview with an offset of 130, and that uitableview is Transparent, only cells will be scrolled and visible.

我的要求是在130的偏移量之内,我想将触摸事件传递到 uitableview 下面的view( pageViewController ),并且该视图不是表视图的超级视图(它是同级视图),但是我将其与表视图重叠.

My requirement is within this offset place of 130, I want to pass touch events to the view(pageViewController) which is below the uitableview and that view is not a superview(It is a sibling view) of table view but I overlapped it with tableview.

因此可以将触摸(水平滑动事件)传递到透明区域(偏移区域为130)中 uitableview 下方的视图;如果是的话,我该怎么办?

So is it possible to pass touch (Horizontal Swiping Event) to the view which is below the uitableview in the transparent area (Offset Area of 130); if yes, what I have to do for this?

推荐答案

有很多 个选项可用于控制iOS中的触摸事件和滚动交互方式.您可以覆盖 hitTest ,可以使用发送给手势识别器的委托消息来说明应在何时触发识别器的组合,等等.在没有详细了解问题的情况下,很难说出哪个是最好的...并且即使那样,您可能会说这部分是风格问题.(不过乍一看,我猜想可能是重写 hitTest 在不同的时间返回不同的视图.)

There are lots of options for controlling how touch events and scrolling interact in iOS. You can override hitTest, you can use delegate messages sent to gesture recognizers to say which combinations of recognizers should fire when, etc. Without seeing your problem in detail it's hard to say which is best... and even then, you might say it's partly a matter of style. (At first blush, though, I'd guess that overriding hitTest to return different views at different times might be it.)

我建议在高级滚动视图和触摸处理技术上观看WWDC 2014视频.该演讲通过解决听起来几乎与您的问题完全相同的问题而起作用,因此您几乎肯定会在其中找到一个好的解决方案.还有许多其他技巧可能会对您应用程序中的其他地方有所帮助.(实际上,如果您有时间,我建议您观看过去几年的WWDC中以UIScrollView为主题的会议……所谓的"Josh& Eliza Show"一直以来都是充满了很棒的演示和有用的见解.)

I'd recommend watching the WWDC 2014 video on Advanced Scrollviews and Touch Handling Techniques. That talk works through solving some problem that sound almost exactly like yours, so you'll almost certainly find a good solution in there. And lots of other tips that might be helpful elsewhere in your app. (Actually, if you have the time, I'd recommend watching the UIScrollView-themed sessions from the past several years' WWDCs... the so-called "Josh & Eliza Show" has always been full of cool demos and useful insights.)

这篇关于如何将触摸事件传递给tableview下的另一个视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆