user1475205
user1475205

Reputation: 1

How to refer to other buttons in my xib file?

I want a button action that will change the button title but also will change other buttons title, I don't know how to refer those buttons (I have 9 (3X3) buttons).

Is there anyway i can refer those by their tags?

Upvotes: 0

Views: 91

Answers (1)

mopsled
mopsled

Reputation: 8505

You can either create an outlet to those buttons, or grab them by their tag value:

UIButton *myButton = (UIButton *)[self.view viewWithTag:TAG_VALUE];
[myButton setTitle:@"New Title" forState:UIControlStateNormal];

The preferred iOS way is to use outlets, but you may also use the tag value of the view you're grabbing.

Upvotes: 1

Related Questions