答案 0 :(得分:1)
在开始播放视频之前尝试这样的事情
var positions = [Int]()
for (idx, recognizer) in (playerVC.view.subviews[0].gestureRecognizers?.enumerated())! {
if recognizer is UIPinchGestureRecognizer || recognizer is UIPanGestureRecognizer {
positions.append(idx)
}
}
for position in positions {
playerVC.view.subviews[0].gestureRecognizers?.remove(at: position)
}
答案 1 :(得分:1)
更安全的方法:
let recognizers: [UIGestureRecognizer] = view.subviews.first?.gestureRecognizers ?? []
for (idx, recognizer) in recognizers.enumerated() {
if recognizer is UIPinchGestureRecognizer || recognizer is UIPanGestureRecognizer {
positions.append(idx)
}
}
for position in positions.reversed() {
view.subviews.first?.gestureRecognizers?.remove(at: position)
}
如果您不使用positions.reversed()
,则在删除第一项并调整数组大小时,应用程序可能会崩溃。