How can I start function when UICollectionView is finished loading?

前端 未结 1 1372
半阙折子戏
半阙折子戏 2021-01-26 18:29
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {

   let cell = collectionView.dequeueReusableCel         


        
相关标签:
1条回答
  • 2021-01-26 19:12

    cellForItemAt is to be used only to create the cells in your table view. It will be called once for each cell in your table (not necessarily at once, but as you scroll into the table view).

    So move your code below in a more appropriate place, like viewDidLoad.

    let returnleft = IndexPath(row: 0, section: 0)
    self.collectionView.scrollToItem(at: returnleft, at:UICollectionViewScrollPosition.left, animated: true)
    
    0 讨论(0)
提交回复
热议问题