Search code examples
iosxcodeswiftibaction

Disable an IBAction


I've created an IBAction from a button on the storyboard. After it is clicked, I want to disable it so its no longer functional. How can I do this?

 @IBAction func b1(sender: AnyObject) {
    displayLabel(1)
}

Solution

  • Create an outlet for your button and set its enabled property to false in your b1 func. Say your outlet is "button1":

        button1.enabled = false