There seem to be about two ways to make a button or a view fire an event when it's clicked.
One is to create a UIView and use a UITapGestureRecognizer,
let iv = UIView() let tap = UITapGestureRecognizer(target: self, action: #selector(handleProfileImageView)) iv.isUserInteractionEnabled = true iv.addGestureRecognizer(tap)
and the other is to use the addTarget function.
let button = UIButton() button.addTarget(self, action: #selector(tapFollowButton), for: .touchUpInside)
I hear the first way can be used on instances of UIView subclasses,
and the second way can be used on instances of UIControl subclasses.
So instances of UIContol subclasses can use both ways.