NSCollectionView仅渲染前100个单元格

时间:2016-04-25 22:01:40

标签: swift storyboard nscollectionview

我正在尝试在NSCollectionView中显示256个单元格。我正在使用Storyboard,但NSCollectionViewItem位于单独的xib中。它在启动时在CollectionView中注册。 DataSource对象包含一个数组(NSMutableArray),其数字在由makeItemWithIdentifier(...)函数提供时将加载到NSCollectionViewItem的representObject中。

func collectionView(collectionView: NSCollectionView, numberOfItemsInSection section: Int) -> Int {
    return dataArray.count
}

func collectionView(collectionView: NSCollectionView, itemForRepresentedObjectAtIndexPath indexPath: NSIndexPath) -> NSCollectionViewItem {
    let item = collectionView.makeItemWithIdentifier("CellItem", forIndexPath: indexPath) as! CellCollectionViewItem
    item.representedObject = dataArray[indexPath.indexAtPosition(1)]
    item.index = indexPath.indexAtPosition(1)
    item.dataSource = self
    return item
}

当应该仅显示(确切地)单元格时,将呈现100个单元格而不是全部256个单元格。数据阵列在任何时候都不会包含100个项目。此外,我的调试输出显示实际上生成了所有NSCollectionViewItems。这意味着问题必须在于渲染集合视图。 NSCollectionView可以立即呈现的项目数量是否有限制?我错过了什么?

当用户缓慢调整窗口大小时,剩余的单元格会出现,如果用户快速调整窗口大小,则会再次消失。视图是否在固定的时间后停止渲染?

Cells appearing on window resize and disappearing again after a click on a cell (which triggers a reload of the reloadData() function

0 个答案:

没有答案
相关问题