Equivalent of ReloadData for NSCollectionView to redraw item views

為{幸葍}努か 提交于 2019-12-11 06:57:58

问题


I have a toggle to change the font attributes. In my NSOutlineView, I call ReloadData to have everything re-render. However, how can I force NSCollectionView to re-render. I tried

cvReader.NeedsLayout= true;
cvReader.Layout();

cvReader.NeedsDisplay = true;
cvReader.Display();

to no avail. Any hints much appreciated.

Update. I also tried

cvReader.NeedsDisplay = true;
cvReader.Window.ViewsNeedDisplay = true;
cvReader.Window.FlushWindowIfNeeded();

As well as assigning the content again. It feels like the item views are cached and not regenerated. Maybe there is a way to clear the item view cache?


回答1:


Turns out that the NSCollectionView item views can be refreshed by setting the ItemPrototype, e.g.,

ItemPrototype = new SomeViewController()

This causes all the existing views to be recreated.



来源:https://stackoverflow.com/questions/22947063/equivalent-of-reloaddata-for-nscollectionview-to-redraw-item-views

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!