Swift 3 TapGestureRecognizer选择器抛出错误

时间:2017-09-18 13:28:08

标签: swift3 uitapgesturerecognizer

我已经查看了其他一些帖子,其中包含添加目标的问题,不仅仅是点按手势和按钮,而且我认为我正确地遵循了格式,但仍然没有成员'没有成员&# 39;错误,这是我的伪代码:

let tapGesture = UITapGestureRecognizer(target: self, action: #selector(self.handlTap(_:)))

func handleTap(_ sender: AnyObject) {
    }

2 个答案:

答案 0 :(得分:1)

使用UITapGestureRecognizer访问任何对象

  let recognizer = UITapGestureRecognizer(target: self, action: #selector(self.expand))
  view.addGestureRecognizer(recognizer)
  func expand(sender:UITapGestureRecognizer){
   if let myImg = sender.view as? UIImageView //or AnyObject you want {

}
  }

答案 1 :(得分:1)

将手势添加到您的视图中:

view.addGestureRecognizer(yourGesture)