I am trying to implement a simple UIButton (tvOS and Swift), but the TouchDown event does not fire. (also tried TouchUpInside).
- In the simulator, I see visually that the button is pressed.
my ViewController.swift code is:
import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let button = UIButton(type: UIButtonType.System) button.frame = CGRectMake(100, 100, 400, 150) button.backgroundColor = UIColor.greenColor() button.setTitle("Test", forState: UIControlState.Normal) button.addTarget(self, action: "buttonAction:", forControlEvents: UIControlEvents.TouchDown) self.view.addSubview(button) self.view.userInteractionEnabled = true } func buttonAction(sender:UIButton!){ NSLog("Clicked") } }
What do I need to do to detect a button click?
Dizzy source share