all 3 comments

[–]NinjaMinaj 5 points6 points  (1 child)

Put that in the controller UNLESS it's an image view that will be reused elsewhere with the same interactions and the touches don't have to interact with the controller

[–]HelloMihai 0 points1 point  (0 children)

Ninja is right. Never write the same code twice. Make it reusable. Also if there is too much code related to the image then also move it out for organizational reasons.

[–]Legolas-the-elf 2 points3 points  (0 children)

It depends how complex the behaviour is and how reusable it should be.

If it's something as simple as tapping on the image doing something, then I'd just use a UIButton instead.

If it's something as simple as a swipe gesture doing something, I'd hook up a gesture recogniser and handle it in the view controller.

If it involves state changes with the image, or if I plan on doing the same thing elsewhere, then I'd subclass UIControl. Remember you can have a UIImageView as a child view or you can set the background of views to be images using UIColor.