A
A
arturios5712018-11-08 00:08:58
Swift
arturios571, 2018-11-08 00:08:58

How to implement only one selected checkbox?

Hello.
There are 7 buttons in the form of a checkbox, I want to make it possible to select only one. For example, if one is selected and you click on another, then the one that is selected becomes not selected, but the one that is clicked is selected. In my head, the current is a sea of ​​\u200b\u200bif ((but I wanted to get by with a little bloodshed
Or maybe I can implement it somehow through the table, I’ll never know!
I’ll thank you for any help!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Konstantin Tsvetkov, 2018-11-08
@tsklab

There are 7 buttons in the form of a checkbox, I want to make it possible to select only one.
It's called RADIOBUTTON .

I
Igor Cherny, 2018-11-08
@freeg0r

put all the buttons in an array, in the method of pressing the buttons you insert for this array

func actionMethod(_ sender: UIButton) {
      buttonsArray.forEach { $.isSelected = $ == sender }
      .
      .
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question