开发者

Detecting tap on the UIImageViews added to UIScrollView

开发者 https://www.devze.com 2023-03-19 19:45 出处:网络
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 Us开发者_运维百科er can scroll either way horizontally

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 Us开发者_运维百科er 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.


When I meet UIScrollView and UIImageView.I always use UIButton instead of UIImageView and use setTag to get which button is pressed.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消