Хорошо, есть только один способ сделать это:
class MyViewController: UIViewController {
@IBOutlet private var collectionView: UICollectionView!
private let panGesture = UIPanGestureRecognizer()
private let tapGesture = UITapGestureRecognizer()
override func viewDidLoad() {
super.viewDidLoad()
panGesture.delegate = self
tapGesture.delegate = self
// Code to assign Gesture Recognizer
}
}
// You should conform your controller to UIGestureRecognizerDelegate
extension MyViewController: UIGestureRecognizerDelegate {
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool {
let touchLocation = touch.location(in: collectionView)
guard let indexPath = collectionView.indexPathForItem(at: touchLocation) else {
return true
}
// let's assume that you want to disable second cell (indexPath.row starts from 0)
let disabledRow = 1
return indexPath.row != disabledRow
}
}
Если вы отправите свой код, я могу помочь вам лучше