1

let me explain you whole scenario:

I'm making the audio record & audio player When I started recording audio.And I starts to click on pause and stop button multiple times like crazy kid and sometimes buttons stop working and got that error.

please help me out if anyone faces that issue once or resolve it

thanks in advance

1
  • why not keep one disabled, eg : if the audio is already playing keep play button disabled, and if its not keep stop button diabled.
    – Geet
    Feb 28, 2018 at 9:48

2 Answers 2

0

In general, you could prevent the user from pressing a button repeatedly or too fast by disabling the button for a short period of time every time the button is pressed.

For example, disable the button for 2 seconds:

func pressButton() {
    button.isEnabled = false
    Timer.scheduledTimer(timeInterval: 2, target: self, selector: #selector(enableButton), userInfo: nil, repeats: false)
}

@objc func enableButton() {
    self.buttonTest.isEnabled = true
}
-2

Turns out that the way I was adding my views inside th view was the main cause of the issue. My apologies!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.