는 collectionView(_ collectionView: UICollectionView, targetIndexPathForMoveFromItemAt originalIndexPath: IndexPath, toProposedIndexPath proposedIndexPath: IndexPath) -> IndexPath
참조 애플의 문서 사용해보십시오 : 항목의 상호 작용 이동하는 동안 https://developer.apple.com/documentation/uikit/uicollectionviewdelegate/1618052-collectionview
를 수집보기는 당신이 제공하려는 있는지 이 메소드를 호출 제안 된 경로보다 다른 인덱스 경로 이 방법을 사용하면 사용자가 에서 항목을 잘못된 위치에 놓지 않도록 할 수 있습니다. 예를 들어 사용자가 특정 섹션에서 항목을 삭제하지 못하게 할 수 있습니다.
그래서 당신은 마지막 셀과 셀을 재정렬 방지하기 위해 원하는 경우 예를 들어, 당신은 할 수 :
func collectionView(_ collectionView: UICollectionView, targetIndexPathForMoveFromItemAt originalIndexPath: IndexPath, toProposedIndexPath proposedIndexPath: IndexPath) -> IndexPath {
if proposedIndexPath.row == data.count {
return IndexPath(row: proposedIndexPath.row - 1, section: proposedIndexPath.section)
} else {
return proposedIndexPath
}
}
우리는 당신을 돕기 위해 더 컨텍스트가 필요합니다. 셀에 관해 달성하려는 레이아웃을 보여주는 스키마 또는 XIB 파일을 제공 할 수 있습니까? 그들은 (움직이지 않는) 특정한 자세를 취하고 있습니까? – Balanced