我想用tapGestureRecognizer初始化我的UIView,我希望每次点击UIView时调用我的ViewController tapHandler func。我认为它应该是这样的:
初始化UIVIew
required init?(coder aDecoder: NSCoder) {
{
super.init(coder: aDecoder)
let tab = UITapGestureRecognizer(target: ViewController, action:
#selector(ViewController.tapHandler(view: self))) }
self.addGestureRecognizer(tab)
}
但它不起作用。如何在ViewControler中将目标设置为ViewController并将其设置为tapHandler?