I've a UIButton which I built in Storyboard. Its title is "Hallo" (Entered in Attributes Inspector) It is connected via an Outlet. In viewDidLoad I did the following:
self.myButton.hidden = YES;
In another method I want to change the title and make the button visible:
[self.myButton setTitle:@"Test" forState:UIControlStateNormal];
self.myButton.hidden = NO;
Now the strange thing: For a few milliseconds I see the old title "Hallo" and then it changes to "Test". How could this be? I could understand this behaviour if I make it first visible and then change the text.
I also had the same issue for the button which I put on uitableview cell. Following code was working for me. It's setting the title for all the status of the button.
[self.myButton setTitle:@"Test" forState:forState:UIControlStateNormal|UIControlStateHighlighted|UIControlStateSelected];
self.myButton.hidden = NO;
Check your title for highlighted state of your button too
[self.myButton setTitle:@"Test" forState:UIControlStateNormal];
[self.myButton setTitle:@"Test" forState:UIControlStateHighlighted];
self.myButton.hidden = NO;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With