KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to dynamically update the title of an IBOutletCollection of UIButton s. I expect the title to be set to the letter 'S' when selected and the text "D|S" when disabled and selected. It wasn't working, so I printed out the titleForState: s and it looks like the title is not getting set properly. Am I using setTitle: forState: correctly? @property (strong, nonatomic) IBOutletCollection(UIButton) NSArray *buttons; ... - (void)updateUI // Calling this from IBAction { for(UIButton *button in self.buttons) { [button setTitle:@"S" forState:UIControlStateSelected]; [button setTitle:@"D|S" forState:UIControlStateSelected|UIControlStateDisabled]; NSLog(@"%@ %@ %@ %@ %d %d", [button titleForState:UIControlStateSelected], [button titleForState:UIControlStateSelected], [button titleForState:UIControlStateNormal], [button titleForState:UIControlStateSelected|UIControlStateDisabled], button.selected, button.enabled); } } Here's the console output: 2013-02-21 21:05:36.070 Buttons[37130:c07] D|S D|S 0 1 2013-02-21 21:05:36.072 Buttons[37130:c07] D|S D|S 0 1 2013-02-21 21:05:36.073 Buttons[37130:c07] D|S D|S 0 1 2013-02-21 21:05:36.073 Buttons[37130:c07] D|S D|S 0 1 2013-02-21 21:05:36.073 Buttons[37130:c07] D|S D|S 0 1 2013-02-21 21:05:36.074 Buttons[37130:c07] D|S D|S 0 1 2013-02-21 21:05:36.074 Buttons[37130:c07] D|S D|S 0 1 2013-02-21 21:05:36.074 Buttons[37130:c07] D|S D|S 0 1 2013-02-21 21:05:36.075 Buttons[37130:c07] D|S D|S 0 1 2013-02-21 21:05:36.075 Buttons[37130:c07] D|S D|S 0 1 2013-02-21 21:05:36.076 Buttons[37130:c07] D|S D|S 0 1 2013-02-21 21:05:36.076 Buttons[37130:c07] D|S D|S 0 1
Tags (comma-separated)
Save Edits
Cancel