I am trying to get a touch event every time an image is touched to update a label and be removed from view. However if I have a single image the touch event below works but because I am animated many images it cannot detect it. I would appreciate any help.
I am trying to get a touch event every time an image is touched to update a label and be removed from view. However if I have a single image the touch event below works but because I am animated many images it cannot detect it. I would appreciate any help.
I would suggest using UIGestureRecognizer objects. If all you want to respond to is taps, use UITapGestureRecognizer.
You can create tap gesture recognizers in your viewDidLoad with your view controller as the target. Add one to each view that you want to respond to taps.
You can either use different action methods for each view, or use the same action method for all of them, and check the view property of the gesture recognizer object that's passed to you to see which view was tapped.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
Thanks for the reply Duncan. Having never used gesture recognizers before i've had a go and was hoping you could point me in the right direction. I can get it to recognize taps in view but not on the Imageviews. The code below detects nothing.
I would suggest using UIGestureRecognizer objects. If all you want to respond to is taps, use UITapGestureRecognizer.
You can create tap gesture recognizers in your viewDidLoad with your view controller as the target. Add one to each view that you want to respond to taps.
You can either use different action methods for each view, or use the same action method for all of them, and check the view property of the gesture recognizer object that's passed to you to see which view was tapped.
__________________
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
Thanks for the reply Duncan. Having never used gesture recognizers before i've had a go and was hoping you could point me in the right direction. I can get it to recognize taps in view but not on the Imageviews. The code below detects nothing.
The code you posted should work. Is self.flakeView non-nil in your viewDidLoad method. Broken outlet/action links are a common cause of code that should work, but doesn't.
Set a breakpoint at the line that adds your gesture recognizer, and check the value of flakeView to make sure it's not nil
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.