UICollectionView と UICollectionFlowLayout をサブクラス化して、単一行のカルーセル ビューを実装しています。ビジュアルは次のようになります。
中央のセルでのみタッチを有効にし、残りを無効にしたい。現在、次のように有効化/無効化ロジックをデリゲート クラスに入れています。
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kButtonCollectionViewCellIdentifier
forIndexPath:indexPath];
// ...
cell.userInteractionEnabled = NO;
return cell;
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView;
{
CGPoint midPoint= CGPointMake(self.collectionView.center.x + self.collectionView.contentOffset.x,
self.collectionView.center.y + self.collectionView.contentOffset.y);
NSIndexPath *indexPath = [self.collectionView indexPathForItemAtPoint:midPoint];
UICollectionViewCell *cell = [self.collectionView cellForItemAtIndexPath:indexPath];
cell.userInteractionEnabled = YES;
}
このロジックを UICollectionView サブクラスに移動したいと思います。では、UICollectionView サブクラスでデリゲート呼び出しをインターセプトし、上記のロジックを追加する方法はありますか?