mardi 19 juin 2018

UIButton Not Responding Properly When Selected

I created a view controller that has four buttons. On each button a image of a checkmark is put on the button but is hidden when the view loads. Once a button is selected the checkmark should show on that button to inform the user that the selection was taken by the system. If a user selects a different button on the screen I would like the original buttons checkmark to disappear and the checkmark to appear on the new selection.

When I run the software and the view loads everything works as it should. The issue is after I make the first button selection. When I click a button the first time after the view loads the checkmark will appear on that one view as it should. Once I try to select the second button I am unable to select it and the checkmark stays on the first button selected.

The code can be seen below for this function:

@IBAction func nomineeSelected(_ sender: UIButton) {
        if sender == optionA {
          checkboxA.hideBox = false
          checkboxA.on = true
          checkboxB.isHidden = true
          checkBoxC.isHidden = true
          checkBoxD.isHidden = true

        } else if sender == optionB {
            checkboxB.hideBox = false
            checkboxB.on = true
            checkboxA.isHidden = true
            checkBoxC.isHidden = true
            checkBoxD.isHidden = true
            checkBoxD.isHidden = true
        } else if sender == optionC {
            checkBoxC.hideBox = false
            checkBoxC.on = true
            checkboxA.isHidden = true
            checkboxB.isHidden = true
            checkBoxD.isHidden = true
        } else  {
            checkBoxD.hideBox = false
            checkBoxD.on = true
            checkboxA.isHidden = true
            checkboxB.isHidden = true
            checkBoxC.isHidden = true

        }
    }

Aucun commentaire:

Enregistrer un commentaire