NSWindow 在单击、调整大小等之前不会绘制
我有一个带有通过 Interface Builder 创建的 NSCollectionView 的窗口。有一个 NSArrayController 绑定到 CoreData 后备存储,该存储在启动时通过触发异步请求进行填充。 NSCollectionView 到 NSArrayController 的绑定等似乎都已就位;但是,该窗口会显示并且是空白的,直到单击该窗口、调整其大小等以强制其重绘。
以下是我尝试过的一些事情,没有任何明显的变化。 (这些在 NSWindowController 类中)
1) 使用 KVO 来监视 CoreData 获取何时完成。此时,我已经尝试了以下所有操作:
[collectionView setNeedsDisplay:YES];
[[self window] setViewsNeedDisplay:YES];
[[self window] flushWindowIfNeeded];
2)添加了 NSProgressIndicator,在启动时隐藏 NSCollectionView,然后当加载完成时(再次通过监视 KVO),我隐藏进度指示器并显示集合视图。
有人对我在这里做错了什么有提示/线索吗?
似乎让事情开始运转。
I have a window with an NSCollectionView created through Interface Builder. There is an NSArrayController that it bound to a CoreData backing store, which is populated at the time of launch by firing an asynchronous request. The binding of the NSCollectionView to the NSArrayController, etc all seem to be in place; however, the window displays and is blank until the window is either clicked, resized, etc to force it to redraw.
Here are some things I've tried without any noticeable changes. (These are in the NSWindowController class)
1) Use KVO to monitor when the CoreData fetch is finished. At this point I've tried any and all of the following:
[collectionView setNeedsDisplay:YES];
[[self window] setViewsNeedDisplay:YES];
[[self window] flushWindowIfNeeded];
2) Added an NSProgressIndicator, hide the NSCollectionView at launch and then when the load is complete (again through monitoring KVO), I hide the progress indicator and show the collection view.
Anyone have an tips/clues on what I'm doing wrong here?
seems to kick things into gear.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
感谢一位朋友在 Twitter 上看到了这个链接,我有了一个解决方案。一旦我的 KVO 触发,添加一个调用:
似乎会让事情开始运转。
Thanks to a friend who saw a link to this on Twitter, I have a solution. Once my KVO fires adding a call to:
seems to kick things into gear.