Tag: Swift uigesturerecognizer

UITapGestureRecognizer发件人是手势,而不是ui对象

我有一个button被调用,我给了它一个UIGestureRecognizer,所以IBAction只在长按button时运行。 您可以通过将UILongPressGestureRecognizer添加到buttoniteself来完成此操作。 然后,您可以控制将该手势识别器拖动到如下function: @IBAction func handleGesture(sender: UIGestureRecognizer) { if sender.state == UIGestureRecognizerState.Began { let labelTap1=UITapGestureRecognizer(target: self, action: "labelTapped:") let alertController = UIAlertController(title: "**I want this to be the title of the button**", message: "This is the description of the function you pressed", preferredStyle: UIAlertControllerStyle.Alert) alertController.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default,handler: nil)) self.presentViewController(alertController, animated: true, completion: nil) } […]