Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
final class SampleViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let button = UIButton(type: .System)
// ...
button.addTarget(self, action: #selector(SampleViewController.buttonTapped(_:)), forControlEvents: .TouchUpInside)
view.addSubview(button)
}
/**
Handle .TouchUpInside event on the button in SampleViewController.
This is a method associated with an action selector, not meant to be called externally.
- parameter button: The button that was tapped
*/
func buttonTapped(button: UIButton) {
print("Selector method called!")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment