在非活动 NSWindow 中刷新 NSTableView

发布于 2024-09-11 17:26:01 字数 258 浏览 5 评论 0原文

我有一个带有主窗口和一个带有表格视图的浮动窗口的应用程序。当我在主窗口中修改浮动窗口的输入(这使浮动窗口处于非活动状态或非关键状态)时,尽管在表视图上调用了 reloadData: ,但表视图不会显示新数据。

我还尝试使用以下内容刷新浮动窗口(因为它包含表格视图)(但没有成功): [[窗口内容视图] setNeedsDisplay:YES];

因此,问题基本上是如何在不是最前面的窗口(如果愿意的话处于非活动状态)的窗口中刷新表格视图。

谢谢!

I have an application with a primary window and a floating window with a tableview in it. When I modify in the primary window the input for the floating window (which makes the floating window inactive or not key) then the tableview does not show the new data in spite of calling reloadData: on the tableview.

I also tried refreshing the floating window (since it contains the tableview) with the following (without success):
[[window contentview] setNeedsDisplay:YES];

So, the question basically is how to refresh a tableview in a window that is not the frontmost window, inactive if you will.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

内心荒芜 2024-09-18 17:26:01

没有代码我们只能猜测......
我的猜测是,你在主窗口中修改的数据不可能与浮动窗口中的数据相同。 (例如,它可以是副本。)
只是一个猜测...

Without code we can only guess...
My guess is that the data you are modifying in the main window could not be the same as the floating window. (It could be a copy for example.)
just a guess...

稳稳的幸福 2024-09-18 17:26:01

我意识到这是一个老问题,但我看到了类似的行为,但找不到解决方案。这就是为我解决的问题:

确保您正在主线程上的浮动窗口中更新表格视图。我正在更新 NSOutlineView 以响应通知,但没有意识到通知已发布在后台线程上。直到我激活其包含窗口后,大纲视图才会更新。

一旦我将该代码移至主线程,它就开始正常工作。

I realize this is an old question, but I was seeing similar behavior and could not find a solution. Here's what solved it for me:

Make sure that you are updating the tableview in the floating window on the main thread. I was updating my NSOutlineView in response to a notification and didn't realize the notification was being posted on a background thread. The outline view did not get updated until I activated its containing window.

Once I moved that code to the main thread, it started working correctly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文