Can multiple buttons have one outlet?

Go To StackoverFlow.com

4

Is there is any way to connect multiple UIButtons to one IBOutlet? I want to to do this so I can disable and change the alpha setting for a couple buttons at the same time rather than having an outlet for each button I want to modify.

2012-04-04 01:04
by Joey


11

Sounds like you might be looking for IBOutletCollection (documentation linked for you).

I haven't actually made use of this yet, and it can only be used with an array of things. But I'm thinking these things (in the array) could be buttons.

2012-04-04 01:09
by Michael Dautermann
some anonymous person attempted to "edit" my post to add this comment (which really should be a comment and not an edit to an answer): "You can place buttons in an IBOutletCollection. If you want to differentiate between them, you need to tag them differently. Also, if you want to access them from the collection, use something along these lines: for(UIButton *button in yourCollectionOfButtons){ if (button.tag ==3){ //do stuff}} - Michael Dautermann 2012-04-04 02:51
Ads