Reputation: 1293
In a game project, a grid of buttons in the the storyboard needs to have their labels updated to reflect game state. Effectively, a button with an image background represents a scrabble tile; at different times the buttons display different tiles (or no value).
I can't treat an IBButton as an outlet. And I can't create a reference to the button unless it's connected to something in the ViewController. I don't see any way to achieve my goal: when a tile changes, change the letter displayed on the button.
This is trivial in any number of programming environments, presentation technologies. If I could at least loop through all the UI elements on the screen, looking for an identifier, I could probably do that. But even that seems to be impossible, at least in the references I have found.
Upvotes: 0
Views: 44
Reputation: 634
First create a connection from the storyboard
@IBOutlet weak private var button1: UIButton!
Then change the title with
button1.setTitle("new title", for: .normal)
Upvotes: 1