2017-03-07 34 views
0

我有一個水平集合視圖和一個按鈕。當按鈕我拍了拍我打電話CollectionView scrollToItem不滾動

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

問題是滾動犯規的那個動畫發生,但如果我做一個斷點scrollToItem進入裏面的方法。

爲什麼發生?

+0

沒有嘗試在主線程跑的? – bisma

+0

檢查indexPath是否正確? –

+0

通過'禁用'重試斷點 – pkc456

回答

-1

嘗試代碼..

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

代碼將您的滾動滾動到水平.. –

相關問題