代码之家  ›  专栏  ›  技术社区  ›  PruitIgoe

Swift 3 TapGestureRecognitor选择器抛出错误

  •  0
  • PruitIgoe  · 技术社区  · 7 年前

    let tapGesture = UITapGestureRecognizer(target: self, action: #selector(self.handlTap(_:)))
    
    func handleTap(_ sender: AnyObject) {
        }
    
    2 回复  |  直到 7 年前
        1
  •  1
  •   Abdoelrhman    7 年前

    将手势添加到视图中:

    view.addGestureRecognizer(yourGesture)
    
        2
  •  1
  •   Nishant Bhindi    7 年前

      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 {
    
    }
      }