Question

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 http://www.quicksnapper.com/files/10513/5329281414A48CEBA2FFE0_m.png

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

Was it helpful?

Solution

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.

OTHER TIPS

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top