I have button that show up a modal view but i want that if the user click it he wont be able to use it again for 90 seconds. how can i do this?
In the IBAction of the button disable the button and set a timer like this:
self.button.enabled = false
NSTimer.scheduledTimerWithTimeInterval(90, target: self, selector: "enableButton", userInfo: nil, repeats: false)
And create the func called when the timer ends counting:
func enableButton() {
self.button.enabled = true
}
sender.isUserInteractionEnabled = false
Timer.scheduledTimer(withTimeInterval: 90, repeats: false, block: { _ in
sender.isUserInteractionEnabled = true
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With