I have a game with win and lose functions. I want to make buttons appear dependent on whether the user has won or lost. I have linked the button via an IBAction and put the following code in my gesture recognizer function which determines whether someone has won. But it comes up with an error saying
"Value of type '(Any) -> ()' has no member 'isHidden'"
How do I reference the Hidden status of a button from another function please? Thank you.
The win button is defined as
@IBAction func winButton(_ sender: Any) {
performSegue(withIdentifier: "segue1", sender: self)
}
The function I'm trying to include it in is as follow -
@IBAction func onTapping(_ sender: UITapGestureRecognizer) {
let systemRed = UIView()
systemRed.backgroundColor = .systemRed
if sender.view?.backgroundColor == systemRed.backgroundColor {
setAllSquares(to: .systemGreen)
timer.invalidate()
winButton.isHidden = false
}
winButton() is a function connected with an @IBAction.
You need to also create and @IBOutlet for the winButton and set that to ishidden.
You should probably remove the current link in the storyboard for winButton and make a new IBAction that has a better action name like "tappedWinButton". Then connect to a new @IBOutlet called winButton.
Then in your code, settings winButton.isHidden will work.
You need to be careful when renaming things in your storyboard, because the connections will get messed up if you create something new with the same name to connect to.