gpt4 book ai didi

iOS:如何在 swift 3 中选择并滚动到 collectionView 中的特定单元格?

转载 作者:搜寻专家 更新时间:2023-10-31 08:19:39 27 4
gpt4 key购买 nike

我想选择并滚动到 collectionView 中的特定 indexPath 并将其居中。我发现了这些功能,但无法将它们结合起来:

collectionView.selectItem(at: indexPath, animated: true, scrollPosition: UICollectionViewScrollPosition.centeredVertically)
collectionView.scrollToItem(at: indexPath, at: .centeredHorizontally, animated: true)
collectionView.scrollToItem(at: indexPath, at: .centeredVertically, animated: true)

提前致谢。

最佳答案

您可以传递选项集 [.centeredHorizo​​ntally,.centeredVertically]

collectionView.scrollToItem(at: indexPath, at: [.centeredHorizontally,.centeredVertically], animated: true)

关于iOS:如何在 swift 3 中选择并滚动到 collectionView 中的特定单元格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46079375/

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