点击手势回来与错误

时间:2016-10-12 13:52:13

标签: swift3 xcode8 uitapgesturerecognizer tap

我正在尝试使用水龙头手势来打印一条线,但它会不断回来,并显示错误消息:

  

libc ++ abi.dylib:以NSException类型的未捕获异常终止   (lldb)

我已将图像链接到分流口,并且没有其他不良连接。

 override func awakeFromNib() {
    super.awakeFromNib()

    let tap = UITapGestureRecognizer(target: self, action: Selector("likeTapped:"))
        tap.numberOfTapsRequired = 1
    likeImage.addGestureRecognizer(tap)
    likeImage.isUserInteractionEnabled = true

}

 func likeTapped(sender: UITapGestureRecognizer) {
    print("yess called")
}

有没有其他人有这个并且有解决方案

1 个答案:

答案 0 :(得分:1)

由于这篇文章,

能够修复它。

How to make UITapGestureRecognizer trigger function

我将代码更改为:

  likeImage.isUserInteractionEnabled = true
    let tap = UITapGestureRecognizer(target: self, action: #selector(self.likeTapped(_:)))
        tap.numberOfTapsRequired = 1
    likeImage.addGestureRecognizer(tap)

}

 func likeTapped(_ sender: UITapGestureRecognizer) {
        print("yess called")
    }