如何在 NSOutlineView 中显示不确定的 NSProgressIndicator?

发布于 2024-07-25 07:00:54 字数 494 浏览 12 评论 0原文

我需要显示项目子项的加载进度。 请告知如何实现进度指示器,就像在邮件应用程序中所做的那样:

大纲视图中的进度指示器
(来源:quicksnapper.com

PS 这里使用指标子视图的源代码: http://snippets.dzone.com/posts/显示/7684

I need to display a progress of loading of item's children. Please advise how to implement a progress indicator like it's done in Mail application:

Progress Indicator in Outline View
(source: quicksnapper.com)

P. S. Here a source code of using indicator sub-views: http://snippets.dzone.com/posts/show/7684

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

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

发布评论

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

评论(3

心病无药医 2024-08-01 07:00:54

这比应有的困难,因为 Apple 不提供 NSProgressIndicatorCell。 虽然表格和大纲视图支持在其中显示自定义单元格的想法,但它们并未设置为轻松支持自定义子视图。

因此,问题就变成了,如何获得一个完整的 NSProgressIndicator 视图来在窗口中的所需位置显示和动画显示,而无法将其实际安装在表视图行中?

我使用的技巧是将 NSProgressIndicator 安装为大纲视图或表格视图本身的子视图。 要找到添加子视图的位置,使其看起来像“在行中”,请使用frameOfCellAtColumn:row:方法。 然后,您可以将进度指示器放置在大纲视图的该位置内。 当您旋转完进度指示器后,您可能不想再显示它,因此只需将其从其超级视图中删除并丢弃即可。

您需要确保在进度指示器上设置所需的自动调整大小标志,以便在调整大纲视图大小时,它会朝正确的方向浮动。

我确信还有其他类似的黑客可以达到预期的最终结果。 我认为没有任何超级干净的方法可以完成这个技巧。

This is harder than it should be, because Apple does not provide an NSProgressIndicatorCell. While table and outline views support the idea of custom cells being displayed within them, they are not set up to easily support custom subviews.

So the trick becomes, how do you get a a complete NSProgressIndicator view to display and animate at the desired spot in your window, without the ability to actually install it in the table view row?

The trick I've used is to literally install the NSProgressIndicator as a subview of the outline or table view itself. To find the location to add the subview, so it looks like it's "in the row", use the frameOfCellAtColumn:row: method. You can then position your progress indicator within that location of the outline view. When you're done spinning the progress indicator, you probably don't want to show it any more, so just remove it from its superview and discard it.

You will want to make sure you set the required autosizing flags on the progress indicator, so that it floats in the correct direction when/if your outline view is resized.

I'm sure there are other hacks like this to achieve the desired end result. I don't think there is any super-clean way to accomplish this trick.

给不了的爱 2024-08-01 07:00:54

Vienna 是一个开源(Apache 许可证)提要阅读器,其源列表中包含此内容。 您应该查看维也纳源代码来了解他们是如何做到的。

Vienna is an open-source (Apache license) feed reader that has this in its source list. You should look at the Vienna source code to see how they did it.

不必你懂 2024-08-01 07:00:54

Viena 的实施并不完美。 将提要添加到文件夹,然后在加载时并且进度指示器正忙于折叠该文件夹。 您将看到进度指示器仍在同一位置运行。

Viena's implementation is not perfect. Add a feed to a folder then as it is loading and the progress indicator is busy collapse that folder. You will see the progress indicator still running in the same location.

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