override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
// initialize cell
if let pickerCell = cell as? SettingsPickerCell {
collectionView.panGestureRecognizer.requireGestureRecognizerToFail(pickerCell.picker.collectionViewController.collectionView!.panGestureRecognizer)
}
return cell
}
上面的代码可以工作,尽管很难看。我有一个 ScrollView 深埋在 View 层次结构中,我需要一种更好的方法来在选择器滚动时禁用 Collection View 滚动。
我尝试使用 exclusiveTouch
属性,但没有帮助。还有比这更好的方法吗?
最佳答案
我认为最好的方法是子类化你的 Collection View 并覆盖
func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?)
和其他相关方法。您可以在那里控制触摸流并解决问题。
关于ios - 如果 subview 正在滚动,则禁用 super View 滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27454024/