2017-03-07 80 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

代码将您的滚动滚动到水平.. –

相关问题