Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

308
Views
¿Cómo deshabilitar uno de los múltiples reconocedores de gestos?

Estoy tratando de deshabilitar 1 de los 3 reconocedores de gestos que he agregado a una vista, ¿alguien sabe cuál es el código correcto?

Esto es lo que tengo hasta ahora:

 // the gesture recognizer i'm trying to disable let tap = UITapGestureRecognizer(target: self, action: #selector(self.handleTap(_:))) myImageView1.addGestureRecognizer(tap) // the code to disable it let allGRs = [currentView.gestureRecognizers] for g in allGRs { if let g as? UITapGestureRecognizer { g.isEnabled = false } }

¡Gracias!

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

¡Espero que esto le pueda ayudar!

  1. Agregue un nombre único a su UITapGestureRecogniser

     let tapName = "100" //Any unique name func addGestureRecognisers() { let view = UIView() // Your view in your context. I just added to test my code let tap = UITapGestureRecognizer(target: self, action: action: #selector(self.handleTap(_:))) tap.name = tapName view.addGestureRecognizer(tap) }
  2. Filtre UITapGestureRecognisers y luego Filtre el resultado por name .

     func disableTapGesture(from view: UIView) { view.gestureRecognizers?.filter({$0.name == tapName}).first?.isEnabled = false }
over 4 years ago · Santiago Trujillo Report

0

Debe asignar la propiedad de nombre a su reconocedor de gestos.

tap.name = "myTapGesture"

Y luego puede recorrer los recozniers y solo deshabilitar el que desee.

 for aRecognizer in view.gestureRecognizers { if let name = aRecognizer.name { if name == "myTapGesture" { aRecognizer.isEnabled = false } } }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!