I am showing multiple images in form of a grid in my content extension. how can I add an different action for every image.
I know we can add action for button. Is it possible to add action for image too.
I am showing multiple images in form of a grid in my content extension. how can I add an different action for every image.
I know we can add action for button. Is it possible to add action for image too.
2
Answers
You can add a
UITapGestureRecognizer
to your image view and differentiate your images usingtags
like this:Objective-C Version:
Swift Version:
If you’re trying to connect Obj-C to Swift. Add your
tags
in Obj-C and import your projects generated Swift header file in your Objective-C header file:For Swift 5 and for one image you can use easily this method.
Then you need to put objc func in your class like below