UICollectionView设置第一个打开索引号

问题描述 投票:1回答:2

我有一个UICollectionView。此CollectionView打开索引号“0”但我希望它打开索引号“2”。我怎么做到的?

set uicollectionview default nsindexpath
2个回答
2
投票
scrollView.setContentOffset(CGPoint(x: 0, y: cellHeight * 2), animated: false)

你可以在swift中使用这一行


1
投票

取决于您的collectionViewcell高度(如果垂直滚动)

你可以添加[scrollView setContentOffset:CGPointMake(0,cellHeight *2) animated:NO];

在你的viewWillApear

© www.soinside.com 2019 - 2024. All rights reserved.