Calculate the number of presses



  • Good afternoon. How do you calculate the number of applications on the screen and the condition (if the number of vents is vent 20, then remove the message)?



  • If a 20-centre is to be at one point,

    override func viewDidLoad() {
        super.viewDidLoad()
    
    let tap = UITapGestureRecognizer(target: self, action: Selector("tap:"))
    tap.numberOfTapsRequired = 20
    self.view.addGestureRecognizer(tap)
    

    }

    func tap(sender: UITapGestureRecognizer) {
    print("tap")
    }

    If anywhere on the screen:

    var numberOfTaps = 0

    override func viewDidLoad() {
    super.viewDidLoad()

    let tap = UITapGestureRecognizer(target: self, action: Selector("tap:"))
    self.view.addGestureRecognizer(tap)
    

    }

    func tap(sender: UITapGestureRecognizer) {
    self.numberOfTaps++

    if(self.numberOfTaps >= 20) {
        print("tap")
        self.numberOfTaps = 0
    }
    

    }


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2