如何在ViewController中使用tapHandler将tapGesture添加到UIView?

时间:2018-05-05 21:23:02

标签: swift

我想用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?

0 个答案:

没有答案