This is the image from app store whenever we search for any app. I also want to add the same scrollview concept in which it show the currentimage with small preview of previous and next image. I am able to make this view with the help of Sample code. But didn't find any solution that how to get index or tagvalue when user tap any of the image. So that I would be able to open the detail page for each image. If Someone has idea about this please help me.
Thanks in advance.
Suppose you have an array with the objects to display and a
UIImageView
to display the image, just do this when setting up the view with the indexi
:where
kImageTag
is any constant > 1 to make sure you don't get a 0 as the tag.Now when the view is selected you can simply check for the tag of the image view.
At the risk of making a recommendation without seeing the full picture of your app, why not use a custom UIButton instead of UIImageViews for this? With a UIButton you can setup an action and pass the sender id, from which you can easily access your tags and pull the data from your array.
And inside of the touchDown: method you simply have to cast the sender to a UIButton in order to access the tag
OR check this out
set tag to images as per you want After adding all imageView successfully you get them click like this :-
I have resolved the issue and really thanks to all to look upon my issue.
Add gesture recognizer to the necessary image view:
Then in the gesture handler get access to the view gesture recognizer attached to:
For those using
storyboards
andswift
:Change tag of every UIView or UIImageView in IB (interface builder) ex:
// code in swift file :
The Best way to achieve what you wish is to add a UITapGesture to your image:
Get the superview of your tap gesture, this will give you the correct indexPath. Try this:
You can increase or reduce the superview's depending on you hierarchy level. Start from one superview and keep increasing till you get the indexPath