Re: Design for showing ridiculously huge number of images in Table View
Re: Design for showing ridiculously huge number of images in Table View
- Subject: Re: Design for showing ridiculously huge number of images in Table View
- From: rajesh <email@hidden>
- Date: Fri, 12 Dec 2008 10:41:32 +0100
I typed in the mail while I was logging off for the home yesterday,
and hence few mistakes , sorry my bad :( ( though it doesn't
effect the way we look at the design )
I sum it up for better understanding.....
Actually , I have an NSOutlineView + NSTreeController .
controller has NSDictionary's and one of which has the image name ,
resolution , etc as keys set on it.
That is all the data I get.
I go ahead and used bindings to set the dictionary to the part of
OutlineTable column ( with Custom Image cells ) in it.
Now in the custom cell, I am looking for the image based on the
Dictionary supplied.
Flow is some thing like this :
Cell gets a display request -> cell looks up if the image is available
if Yes :
It displays the image ( pretty straight forward )
If no:
It places a request and as it might take some time for availability
( depending on the network speed and size of the image ) I display a
placeholder image , as well I am now registered for the notification
in the init section of cell.
My question is:
do I add observer at cell level OR the controller level ( dataSource
level ) ?
I am confused because the user might just scroll through the tabel ,
in first go there are definitely no images , at the same time the
cells which placed request for images might no longer be in the
visible-rect of the Outline Table && every cell receives notification
of every other image that got downloaded , so Is there any way to
determine if the current cell which just got notified to determine if
its in the visible-rect.
as pointed by Jean-Daniel I think visible part of table-thing is been
taken care.
My application is kind of huge and already has many threads running ,
I am considering not to use it , unless thats my last shot. ( iv seen
the photo search example before this and dropped it cause of Thread
thing )
I am kind of newbie + most of the work is in patch & workarounds , but
I want this app to be design perfect.
Luckily my deployment target is only 10.5+
If you got till this line , I thanks you got tons of patience ;)
Thanks
~Rajesh
On Dec 11, 2008, at 6:35 PM, Corbin Dunn wrote:
On Dec 11, 2008, at 9:21 AM, Jean-Daniel Dupas wrote:
Le 11 déc. 08 à 17:55, rajesh a écrit :
Hi All,
I implemented NStableView which contains few "columns" with
NSImageCells , there are huge number of rows ( for the nightmare )
images are requested over the network and hence images are never
readily available.
but part of my framework intimates me whenever an image is
downloaded and i precisely know for which of the rows image has
been downloaded.( so far good ).
I am trying to register an observer in the custom cell class of
the ImageCell I mentioned.
So whenever display is requested on the cell , it checks for the
image in downloads , if it isn't available it draws empty image
else it places an request and waits for the image.
After image is downloaded observer tries to invoke the drawing
again.
This way only cells which are actually in "screen display" get
drawn , hence I am supposing there would less traffic and leads to
efficient drawing.
Is this a right practice ? or completely unethical ?
Thanks
Rajesh
Did you try to simply use a table view data source and the built-in
optimization mechanism before trying to do such complex things ?
For example, NSScrollView, and so NSTableView (which are generally
embedded in scrollview) only draw the visible part, and ask data
source only the visible value.
So write a simple data source that returns the image or nothing if
it is not available in the -getValue.... method.
This will work, and it sounds like what rajesh is proposing.
The disadvantage of this approach is that type selection will
attempt to load a preparedCellAtColumn:row: -- that includes
touching off -willDisplayCell and -objectValue, which will cause the
datasource to unnecessarily load the image.
There are two easy work arounds to avoid that performance problem:
1. Turn off type selection: setAllowsTypeSelect:NO
2. Implement the delegate method:
- (NSString *)tableView:(NSTableView *)tableView
typeSelectStringForTableColumn:(NSTableColumn *)tableColumn row:
(NSInteger)row AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
corbin
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden