I am learning swift 3, and following this guide, which was written before swift 3 and xcode 8.1, as such, I had to change a few things along the way. https://developer.apple.com/library/content/referencelibrary/GettingStarted/DevelopiOSAppsSwift/Lesson5.html#//apple_ref/doc/uid/TP40015214-CH19-SW1
Here is the code to the point where I am stuck in creating the RatingControl. The problem is ratingButtonTapped does not get called. Doubly verified using a breakpoint. I do see that the initialization function is called, and so I know that button.addTarget is executed. Any ideas on what I am doing wrong?
import UIKit
class RatingControl: UIView {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
let button = UIButton(frame: CGRect(x: 0, y: 0, width: 44, height: 44))
button.backgroundColor = UIColor.red
button.isEnabled = true
button.addTarget(self, action: #selector(RatingControl.ratingButtonTapped(button:)), for: .touchDown)
addSubview(button)
}
func ratingButtonTapped(button: UIButton) {
print("Button pressed ")
}
}