检测添加到 UIScrollView 的 UIImageView 上的点击
我正在 iPhone 中开发一个应用程序,它有一个 UIScrollView,我向其中添加了一组图像视图(如缩略图,使用循环)。用户可以水平滚动任一方向并选择特定图像。用户点击的图像必须显示在单独的 UIImageView 中。我已经实现了直到检测到 UIScrollView 上的点击。但我不知道如何确定哪个图像收到了点击,以便我可以在 UIImageView 中显示该图像的预览。如何实现这一目标?对此有任何帮助将不胜感激!提前致谢。
I am developing an application in iPhone which has a UIScrollView to which I have added an array of image views (like thumbnails,using loop). The User can scroll either way horizontally and select a particular image. The image on which the user taps has to displayed in a separate UIImageView. I have achieved till the detection of tap on the UIScrollView.But I dunno how to determine which image received the tap so that I can show a preview of that in the UIImageView. How to achieve that ? Any help on this would be appreciated ! Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当我遇到 UIScrollView 和 UIImageView 时,我总是使用 UIButton 而不是 UIImageView 并使用 setTag 来获取按下了哪个按钮。
When I meet UIScrollView and UIImageView.I always use UIButton instead of UIImageView and use setTag to get which button is pressed.
如何捕捉水龙头?如果它是由 UIGestureRecognizer 完成的,那么您不应该忘记手势识别器只能添加到一个对象。因此,您无法仅通过一个手势识别器捕获对多个对象的点击。因此,在创建这些图像视图的循环中,还会创建一个绑定该图像视图的 UITapGestureRecognizer。
How do you capture the tap? If it's done by UIGestureRecognizer then you should not forget that a gesturerecognizer can be added only to one object. So you can not catch taps on multiple objects via just one gesturerecognizer. So, in your loop where you create those imageviews also create a UITapGestureRecognizer bound the that imageview.