I currently have a subview that is created and added to a UIView in ViewDidLoad() . I UIGestureRecognizers use UIGestureRecognizers to detect touch and display a specific button. My current code is:
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) }
The handleTap() function is a simple test to see if handleTap() recognized. This code does not call UIAlert when clicked? What am I missing?
ios iphone swift uiview uigesturerecognizer
Andrew Walz
source share