iOS。如何连续平移一系列视图?
我有一个缩略图网格,每个缩略图都是一个 UIView。每个缩略图都附加了一个平移手势。如果平移手势从一个缩略图开始,则后续缩略图不会确认平移手势,即使我的手指确实在它们上面移动。即使手势不是在缩略图中启动,如何让所有缩略图对平移手势做出反应?
谢谢,
道格
I have a grid of thumbnails each of which is a UIView. Each thumbnail has a pan gesture attached. If a pan gesture begins on one thumbnail, subsequent thumbnails do not acknowledge the pan gesture even though my finger is indeed moving across them. How do I get all thumbnails to react to a pan gesture even if the gesture did not initiate in the thumbnail?
Thanks,
Doug
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我假设您想要做的基本上是滚动浏览二维缩略图数组?如果是这种情况,请尝试将缩略图放入 UIScrollView 中。这应该可以处理图片的平移。如果您想在点击缩略图时执行某些操作,则将 UITapGestureRecognizers 放入每个单独的缩略图中。
I'm assuming what you're trying to do is basically scrolling through a 2d array of thumbnails? If that's the case, try putting your thumbnails into a UIScrollView. This should take care of panning through pictures. Then put UITapGestureRecognizers in each individual thumbnail if you want to perform some action upon tapping a thumbnail.
将平移手势附加到超级视图,并使用 hitTest:inPoint: 来确定手势正在移动的缩略图。
Attach the pan gesture to the superview, and use hitTest:inPoint: to determine which thumbnail the gesture is moving through.