【问题标题】:iOS: How to select and scroll to a specific cell in a collectionView in swift 3?iOS:如何在swift 3中选择并滚动到collectionView中的特定单元格?
【发布时间】:2018-02-15 04:33:40
【问题描述】:

我想选择并滚动到 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)

提前致谢。

【问题讨论】:

    标签: ios swift swift3 uicollectionview uicollectionviewcell


    【解决方案1】:

    你可以传递选项集[.centeredHorizontally,.centeredVertically]

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-10-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多