To disable cell reuse, simply delete the cell with a specific identifier for this cell pointer path and register that identifier before starting work.
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { NSString *identifier = [NSString stringWithFormat:@"Identifier_%d-%d-%d", (int)indexPath.section, (int)indexPath.row, (int)indexPath.item]; [collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:identifier]; UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
Please note that reuse is not completely disabled in the above method, since for each cell there is an identifier that everyone will probably need. But if you need to completely disable cell reuse, you can do the following.
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { static int counter = 0; NSString *identifier = [NSString stringWithFormat:@"Identifier_%d", counter]; [collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:identifier]; UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath]; counter++;
IMPORTANT : I just answer this question here, it is completely not recommended , especially this second method. I use this first method in the case where I have multidirectional scrolling, and there are some delegate methods regarding focusing on tvOS that I need to call for each cell.
Alejandro Cotilla
source share