I have a bunch of UIButton
s (10-15 of them) in one of my Views. I want to display them as an image without the title text, so what I did was set the image for the Button through the storyboard, and then set an empty title for the button.
I want to react differently when each button is pressed. There are a couple of solutions that I can think of off the top of my head, and I'm wondering which would make the most sense, software engineering-wise:
IBAction
(too many methods added)IBOutlet
(how to differentiate between the buttons, still? Use ===
?)IBAction
, unique tags for each button (this is what I'm doing for now as it's simplest and it works, but aren't tags a bit hacky?)[UIView]
outlet array (is it possible to hide the titles from the storyboard, or must I do it programmatically from the View Controller?)Some solutions you thought of are viable, some others aren't (connecting @IBOutlets
and trying use the equal operator, or hiding the button's title).
I would recommend you to simply keep using UIButton
tags (as that's what tags are there for) and use a single entry-point @IBAction
. You will then be able to identify each button by their tag.
Subclassing your buttons might seem a bit overkill if you're only trying to identify them...