簡體   English   中英

CollectionView scrollToItem不滾動

[英]CollectionView scrollToItem does not scroll

我有一個水平收集視圖和一個按鈕。 當我點擊按鈕時,我打電話

let indexPath : IndexPath = IndexPath(item: item, section: 0)
collectionView.scrollToItem(at: indexPath, at: .centeredHorizontally, animated: true)

問題是滾動動畫不會發生,但是如果我在scrollToItem上創建一個斷點,它將進入方法內部。

為什么會發生?

試試那個代碼..

collectionView.scrollToItemAtIndexPath(
        NSIndexPath(forItem: 0, inSection: startIndex),
        atScrollPosition: .None,
        animated: false)
 }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM