I want to used image view from nos. of image views in scroll view on single tapping any particular image view.
how can I get image tag from different image views on tapping on it
1.1k views Asked by Harshal At
4
There are 4 answers
0
On
Create a button and set image as background.while creating button you can set tag like
button.tag=yourtag;//your tag integer value
[button addTarget:self action:@selector(buttonTouched:) forControlEvents:UIControlEventTouchDown];
[button setBackgroundImage:[UIImage imageNamed:@"img.png"] forState:UIControlStateNormal];
and implement this function in your clss
- (void)buttonTouched:(UIButton *)sender
{
NSLog(@"touched %i",[sender tag]);
}
while tapping the particular button this function will get called.
If you are insistent on using images instead of buttons you can use Gesture Recognizer. Create an imageView and enable its userInteraction
Now allocate a gesture Recognizer object and add it to your imageView...
Now in the selector "singleTap" you can do whatever your action is..
Hope this help...cheers....