Sto tentando di aggiornare dinamicamente il titolo di uno IBOutletCollection
di UIButton
s. Mi aspetto che il titolo per essere impostato suUIButton -setTitle: forState: sembra non funzionare
- la lettera 'S' quando selezionato e
- il testo "D | S" quando disattivato e selezionato.
Non funzionava, quindi ho stampato il titleForState:
e sembra che il titolo non sia impostato correttamente. Sto usando setTitle: forState:
correttamente?
@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);
}
}
Ecco l'output della console:
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
Non vedo nessun altro modo nel riferimento. C'è qualche altro metodo per farlo? – ydmm