jeudi 30 avril 2015

Checkbox is not checking

I have a method that gets called when a button (checkbox) is clicked that should change the background image of the button. I have an NSLog that tells me that the method was called but the image never changes. I can't figure out why.

Thanks for the help!

let checkedImage = UIImage(named: "checkedBox")
let uncheckedImage = UIImage(named: "uncheckedBox")

func checkboxClicked(sender: UIButton!) {
    if sender == self {
        if isChecked == true {
            NSLog("Change background image")
            sender.setBackgroundImage(checkedImage, forState: .Normal)
            isChecked == false
        } else {
            NSLog("Change background image")
            sender.setBackgroundImage(uncheckedImage, forState: .Normal)
            isChecked == true
        }
    }
}




Aucun commentaire:

Enregistrer un commentaire