In my program, I use a scroll view as the background view. Then, I add several images on the scroll view. Also, I allow the users to touch the image in order to trigger some actions. However, the images attached on the scroll view cannot be detected when they were touched. I use the following code my the touch event:
UITouch * touch = [[event allTouches] anyObject];
Did I do something wrong? How can I solve this problem? Thank you very much!
You can use UIImageView to track touches, and also set
myImageView.userInteractionEnabled = YES, since the default is no for imageviews.If you want to detect a tap on the image you can do this:
and implement your selector: