gpt4 book ai didi

ios - UICollectionView,如何防止移动一个单元格

转载 作者:可可西里 更新时间:2023-11-01 17:03:28 25 4
gpt4 key购买 nike

最近在研究collection view。我需要让一些单元格固定在它们自己的索引路径中,这意味着它们不应该被其他单元格交换并且不被拖动。我现在可以使用 *- (BOOL)collectionView:(UICollectionView *)collectionView canMoveItemAtIndexPath:(NSIndexPath )indexPath 来防止它们被拖动。我无法阻止它们被其他细胞交换。

有人遇到同样的问题吗?

谢谢

最佳答案

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
}
}

关于ios - UICollectionView,如何防止移动一个单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47528344/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com