我們有一個集合視圖。我做了一個水平顯示日期的日曆&我水平滾動日期。現在在屏幕上我只看到3-4個日期。現在我想在顯示日曆屏幕時自動滾動到特定的選定日期。因此,我想要滾動到的日期不可見。如何在swift中滾動到集合視圖中的某個特定索引
爲此我得到了特定單元格的索引路徑。現在我正在試圖將其滾動到特定的indexpath。
func scrollCollectionView(indexpath:IndexPath)
{
// collectionView.scrollToItem(at: indexpath, at: .left, animated: true)
//collectionView.selectItem(at: indexpath, animated: true, scrollPosition: .left)
collectionView.scrollToItem(at: indexpath, at: .centeredHorizontally, animated: true)
_ = collectionView.dequeueReusableCell(withReuseIdentifier: "DayCell", for: indexpath) as? DayCell
}
請告訴我該如何實現它?
看起來像調用scrollCollectionView有問題。你從哪裏調用這個方法? –
就在我的收藏視圖準備就緒後 – Techiee
如果您將代碼發佈到創建,準備並最終添加收藏視圖供我們查看的地方,將會有所幫助。 –