I have a view which has scrolling images + paging. I have added these images on a UIVIEW and have added this UIView to main view. I want to detect click event on images within scrollview and handle them in main view.
How do I do it?
Please help
You can solve the problem with a gesture recognizer.
// In the view controller where you create the subviews
// (not sure from your question, but I think you are adding image views to a scroll view
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake...];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imageViewTapped:)];
[imageView addGestureRecognizer:tap];
Now, this will get called when the image view gets tapped
- (void)imageViewTapped:(UITapGestureRecognizer *)gr {
UIImageView *theImageViewThatGotTapped = (UIImageView *)gr.view;
}
Use Gesture simple one
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake...];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imageViewTapped:)];
[imageView addGestureRecognizer:tap];
And call the selector method and do what ever u want..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With