同时识别多个手势 shouldRecognizeSimultaneouslyWithGestureRecognizer
新创建一个类继承UIScrollView 实现手势代理方法
self.panGestureRecognizer.delegate = self 只能是 scrollview 否则崩溃
'UIScrollView's built-in pan gesture recognizer must have its scroll view as its delegate
class THMarketScrollView: UIScrollView {
override init(frame:CGRect) {
super.init(frame:frame)
self.panGestureRecognizer.delegate = self
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
extension THMarketScrollView: UIGestureRecognizerDelegate {
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith shouldRecognizeSimultaneouslyWithGestureRecognizer: UIGestureRecognizer) -> Bool {
return true
}
}
参考 //www.greatytc.com/p/dc8f64ca18ca
//www.greatytc.com/p/040772693872
//www.greatytc.com/p/b88a1f877ffa