Agregar UIGestureRecognizer a la subvista programáticamente en Swift
Actualmente tengo una subvista que se crea y se agrega a UIView en ViewDidLoad (). Estoy intentando usar UIGestureRecognizers para detectar un toque y mostrar un botón en particular. Mi código actual:
override func viewDidLoad() {
super.viewDidLoad()
architectView = CustomClass(frame: self.view.bounds)
self.view.addSubview(architectView)
let gestureRecognizer = UITapGestureRecognizer(target: self, action: "handleTap:")
gestureRecognizer.delegate = self
architectView.addGestureRecognizer(gestureRecognizer)
}
func handleTap(gestureRecognizer: UIGestureRecognizer) {
let alert = UIAlertController(title: "Alert", message: "Message", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "Click", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
}
La función handleTap () es una prueba simple para ver si se reconocen los grifos. Este código no activa la alerta UIA cuando se presiona? ¿Qué me estoy perdiendo?