My code originally worked.
IBAction func clickedon(_ sender: UIButton) {
if(gamestate[sender.tag] == 0 && gameisactive == true){
gamestate[sender.tag] = activeplayer
if (activeplayer == 1){
print("working")
sender.setImage(UIImage(named:"Cross.png"), for: UIControlState()) <-----------
activeplayer = 2
}
else {
print("working2")
sender.setImage(UIImage(named:"Nought.png"), for: UIControlState()) <-----------
activeplayer = 1
}
}
These two pieces of code that installed the image worked. These buttons have nothing to do with their image. When they are clicked, I want them to switch to these images. These images are located in the folder with the view controller. I do not know why they stopped working. I commented on all the other code to find out if this might be a problem, but it doesn't seem to be. Print operations print in both cases. This is just a given image that does not seem to do anything. No mistake, she just does nothing.
UIControlState(). -, , . . , , !