问题
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