是否可以使UIGestureRecognizer在AVPlayerViewController中工作?

时间:2015-10-23 14:17:07

标签: ios swift uigesturerecognizer avplayer avplayerviewcontroller

我试图让视频播放器通过捏合来关闭,但没有任何成功。

func playVideo(video: MyVideoClass) {
    let playerVC = AVPlayerViewController()
    playerVC.player = AVPlayer(URL: NSURL(string: video.videourl)!)

    let pinchy = UIPinchGestureRecognizer(target: self, action: "handlePinchGesture:")
    playerVC.view.addGestureRecognizer(pinchy)

    self.presentViewController(playerVC, animated: true, completion: {
        playerVC.player!.play()
    });
}

func handlePinchGesture(sender: AnyObject) {
    print("Received gesture from \(sender)");
}

捏视频播放器UI此时无效。

1 个答案:

答案 0 :(得分:2)

我过去通过在视频播放器上放置一个透明的UIView解决了这个问题。我将捏合手势添加到透明UIView,当它被处理时,我解除了它下面的视频播放器。