In IB I have a view with a UIButton of Type Custom, it has no image and the Title is set as “#placeholder”
The view is attached to a class that provides an IBOutlet and an IBAction for the button.
I set the button title with this: ViewClass.ButtonOutlet.titleLabel.text = @"%@",stringifiedVariable; whenever I need to.
This works ok. However, when I click the button, the titleLabel.text reverts back to “#placeholder”.
I tried unchecking ‘Highlighted Adjust Image’ in the Drawing section (attributes tab) in the Inspector but the behaviour was still the same.
Can this change be prevented? or is there a better pattern that I should be using?
UIButton has a special method for setting the label.
For instance
Check the documentation for more details.