Ios UIAPTgestureRecognitor不适用于UIView动画

Ios UIAPTgestureRecognitor不适用于UIView动画,ios,swift,animation,uiview,uitapgesturerecognizer,Ios,Swift,Animation,Uiview,Uitapgesturerecognizer,当我在UIImage动画时点击它时,我试图调用一个动作。 我见过类似的问题,但我无法将这些解决方案应用到我的案例中。 请帮忙 代码9.2 斯威夫特4 您刚刚错过了一行,启用了视图上的用户交互 override func viewDidLoad() { super.viewDidLoad() // action by tap let gestureSwift2AndHigher = UITapGestureRecognizer(target: self, action:

当我在UIImage动画时点击它时,我试图调用一个动作。
我见过类似的问题,但我无法将这些解决方案应用到我的案例中。 请帮忙

代码9.2 斯威夫特4


您刚刚错过了一行,启用了视图上的用户交互

override func viewDidLoad() {
    super.viewDidLoad()

    // action by tap
    let gestureSwift2AndHigher = UITapGestureRecognizer(target: self, action:  #selector (self.actionUITapGestureRecognizer))
    myImageView.isUserInteractionEnabled = true
    myImageView.addGestureRecognizer(gestureSwift2AndHigher)

}

您需要像这样传入选项
.allowUserInteraction

UIView.animate(withDuration: 10, delay: 0, options: .allowUserInteraction, animations: {
    ...
})

勾选“我看到过类似的问题,但我无法应用这些解决方案”这些解决方案是什么?thnx,但这一行无助于此部分“\u发件人:UITapGestureRecognizer”无需更改sender将通过特定UITapGestureRecognizer进行验证我明白,但是当ImageView动画时点击操作仍然不起作用。您可以共享动画功能吗?请看高一点,我在我的问题中已经这样做了“//在出现之前隐藏UIImage覆盖func ViewWillDisplay(u动画:Bool){super.viewWillDisplay(动画)myImageView.center.y+=view.bounds.height}//在显示后显示UIImage,并使用动画覆盖func viewDidDisplay(uAnimated:Bool){super.viewDidDisplay(动画)UIView.animate(持续时间:10,动画:{self.myImageView.center.y-=self.view.bounds.height}”
  let tapGesture = UITapGestureRecognizer(target: self, action: #selector(self.clickedImageView(_:)))
  myImageview.isUserInteractionEnabled = true
  myImageview.addGestureRecognizer(tapGesture)

// MARK: - Gesture Recognizer action

    func clickedImageView(_ sender: UITapGestureRecognizer) {
       // Write your action here.
    }
UIView.animate(withDuration: 10, delay: 0, options: .allowUserInteraction, animations: {
    ...
})