Link to home
Start Free TrialLog in
Avatar of Philippe Renaud
Philippe RenaudFlag for Canada

asked on

UIIMageView ID ?

Hello EE,

I was wondering if it was possible in XCode to put a tag or an ID to an UI Image view? My main concern is that once a user has touch the image I would to do something. But how can I know that he touches picture No. 3? or 2... or 6?

If it was possible to have an ID or tag or something so I can place the pictureID that comes from my database I could do anything I want...

any idea?
Avatar of darbid73
darbid73
Flag of Germany image

All views in iOS have a tag property.

See here for the tag property..
Apple Reference for UIView

When I need to do what you want to do I either set the tag property in Interface builder or when creating the view with

imageView.tag = 101;

Open in new window


Then somewhere at the top I have this

#define pic1 101

Now when I want to check what has been touched I use a test like this...

imageView.tag = pic1

Open in new window

Avatar of Philippe Renaud

ASKER

ok thanks.

but what if the ID or the value is a String?  tag i think is only integeR?
the id cannot be a string, thus the reason why I define it as a string to make more sense.
Alright for the Tag.

But one last thing, do you have an example on how you retrieve the tag on when you touch the image?

even if the tag is set, im confused on how I get the info on when the user touches the image he wants..
ASKER CERTIFIED SOLUTION
Avatar of darbid73
darbid73
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes sorry should had done a new question.
thanks