Button tapping code question

Discussion in 'iOS Programming' started by theprizerevealed, Apr 6, 2017.

  1. theprizerevealed macrumors member

    Feb 26, 2016
    how do I cause a button's code to ignore more than one tap?
  2. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    You can disable the button in your action method when it receives the first tap. Alternatively you can just ignore the second tap while it's doing something.

    button.isEnabled = false
  3. theprizerevealed, Jul 2, 2017
    Last edited: Jul 2, 2017

    theprizerevealed thread starter macrumors member

    Feb 26, 2016
    Thank you for your reply, although your answer would be helpful during certain scenarios that I might encounter; it interferes with other code that I might wish to implement in the button and the graphical user effect is not quite suitable. I found another snippet of code that I thought I should share because it works nicely: it controls the responsiveness of a particular button without affecting the entire button code

     self.buttonname.isUserInteractionEnabled = false 
    A modified version of this code snippet can affect the whole view controller after pressing a particular button

     self.view.isUserInteractionEnabled = false 

Share This Page