【发布时间】:2017-04-08 18:36:13
【问题描述】:
我们有一个集合视图。我制作了一个水平显示日期的日历,并且水平滚动日期。现在在屏幕上我只看到 3-4 个日期。现在我想在显示日历屏幕时自动滚动到特定的选定日期。所以我想要滚动到的日期还不可见。
为此,我得到了特定单元格的索引路径。现在我正在尝试将其滚动到特定的索引路径。
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好像有问题。你从哪里调用这个方法?
-
在我的收藏视图准备好之后
-
如果您将代码发布在您创建、准备并最终添加您的集合视图以供我们查看的位置,将会很有帮助。
标签: ios iphone arrays swift uicollectionview