UICollectionView reorders an integral cell

I am creating a UICollectionView with iOS 9 cool reorder function. I can make the cell still by returning No to the datasource function - (BOOL)collectionView:(UICollectionView *)collectionView canMoveItemAtIndexPath:(NSIndexPath *)indexPathfor this pointer path.

However, I found that the cell can be replaced with moving elements, which is not expected.

For example,

We cannot move the third element (screenshot).

But it can be the target index path to move another cell (screenshot).

Any good ideas so that the 3rd cell is really fixed?

+4
source share
1 answer

Suppose an element in indexpath = {x, y} cannot be moved. Try using the following delegate method.

collectionView(_:targetIndexPathForMoveFromItemAtIndexPath:toProposedIndexPath:)

{x,y}, . Ex {x+1,y}

:

, , , . , . , .

+9

Source: https://habr.com/ru/post/1624720/


All Articles