iOS / Swift UIImageView(.jpg)无法识别我的轻拍手势?

当我的图像被点击时,我有一个简单的代码块来播放声音。 但是,当我点击我的图像,水龙头甚至不被识别。

我相信这是真实的,因为在点击图像时,handleTap函数中的println不会打印任何内容。

谁能给我一些见解,问题可能在哪里?

var coinSound = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("wavSampleSound", ofType: "wav")!) var audioPlayer = AVAudioPlayer() override func viewDidLoad() { super.viewDidLoad() loadSound() let gesture = UITapGestureRecognizer(target: self, action: "handleTap:") gesture.delegate = self myImage.addGestureRecognizer(gesture) } func loadSound() { audioPlayer = AVAudioPlayer(contentsOfURL: coinSound, error: nil) audioPlayer.prepareToPlay() } func handleTap(gesture: UITapGestureRecognizer) { let playsSound = self.audioPlayer.play() println("\(playsSound)") } @IBOutlet weak var myImage: UIImageView! 

}

请注意, UIImageViewuserInteractionEnabled的默认设置为false 。 你想把它设置为true