B
B
Boldy2015-06-29 04:01:16
Apple Xcode
Boldy, 2015-06-29 04:01:16

How to get the name of a UIView in Swift?

51c80be6eecd4ea49c3894f412da21dd.png
How can I programmatically get "b1" in the buttonClicked(sender: UIButton) function?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
An, 2015-06-29
@Boldy

What you want to do is done through the tag property.
In the properties of the view (where the color is selected) put down the tag for all buttons from 1 to n (the tag must be a number)
.
Also, google tutorials with IBCollection, here it asks for it
. Oh yes, you are there, I see you are doing tic-tac-toe. First, kill the grid view, namely, make borders near the buttons (google the borderColor uiview tags)
And most importantly, if you still want to make tic-tac-toe, look for the spritekit's tutorial. Uikit for such purposes is the choice of a real Jedi

A
Alexander Tikhonov, 2015-06-29
@tikhonov666

stackoverflow
If you have 4 UITextField added in your code, then they will be displayed in the left window like this
TextField
TextField
TextField
TextField
Which is not very convenient and in order to distinguish them in Xcode, you can rename them by changing the Label field. Nothing more can be done about it.
If you want to pull out the name of the button in the code, then in the interface builder you link this button and your IOBOtlet *button and then write self.button.titleLabel.text in the code

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question