jeudi 20 avril 2023

Select and deselect radio buttons in swift

I've been trying to program these buttons. but these two functions can't work in same time, How can I fix this?

    @IBAction func buttonPressed(sender: AnyObject) {
        if let radioIn = sender as? UIButton {
            if radioIn.isSelected {
                // set deselected
                radioIn.isSelected = false
            } else {
                // set selected
                radioIn.isSelected = true
            }
        }
    }
    
    @IBAction func radioSelect(_ sender: UIButton) {
        if sender == radioIn{
            radioIn.isSelected = true
            radioOut.isSelected = false
        }else{
            radioIn.isSelected = false
            radioOut.isSelected = true
        }
    }



Aucun commentaire:

Enregistrer un commentaire