• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Lazy Loading of images
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Lazy Loading of images


  • Subject: Re: Lazy Loading of images
  • From: "Johannes Fahrenkrug" <email@hidden>
  • Date: Mon, 11 Aug 2008 10:09:51 +0200

Kyle,

Thank you very much, that was what I needed to know!!

- Johannes

On Sun, Aug 10, 2008 at 8:09 PM, Kyle Sluder
<email@hidden> wrote:
> On Fri, Aug 8, 2008 at 9:52 AM, Johannes Fahrenkrug
> <email@hidden> wrote:
>> I'd like to display placeholder images until the table cell gets
>> displayed and then load the actual thumbnail, replacing the
>> placeholder image with the real thumbnail once it has loaded.
>> What would be the best way to do this? I'm thinking of something on
>> the lines of a proxy object...
>
> Are you using the NSTableView data source API?  I think that would be
> easier for what you want to do.  I'd create a placeholder NSImage at
> first, and when I'm asked for the data for my NSImage column, if I
> haven't yet finished downloading the image for that particular row,
> give the NSTableView my placeholder image.  Then, once the image has
> finished downloading, call [myTableView
> setNeedsDisplayInRect:NSIntersectionRect([myTableView
> rectForColumn:indexOfImageColumn], [myTableView
> rectForRow:rowOfUpdatedItem])].
>
> Remember that the rows of an NSTableView don't actually exist as one
> large dataset, so there isn't a one-to-one table cell to NSCell
> correspondence.  Instead, each NSTableColumn has its own cell, that it
> uses like a rubber stamp.  When a region of the table is marked as
> dirty (setNeedsDisplay:/setNeedsDisplayInRect:), the table view
> figures out which columns are affected, and tells them to draw
> themselves.  Each column then asks for the data for each table cell
> that needs to be redrawn, and passes this value off to the NSCell
> assigned to that column, which does the real drawing.
>
> So your image column has an NSImageCell.  When you start scrolling,
> the NSTableView figures out which logical row and column numbers have
> just been revealed by your scrolling maneuver, and kicks off the above
> process.  Your data source is asked "alright, row 12 column 2 needs to
> be painted, gimme the data", and then hands that data off to the cell
> belonging to the column.  The dirty little secret is that from the
> table view's perspective, there aren't actually any rows at all; it
> just does a bunch of math based on where the scroll point is located
> to convert graphics coordinates to logical rows.  Your data source is
> none the wiser.
>
> --Kyle Sluder
>



--
http://blog.springenwerk.com
_______________________________________________

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

References: 
 >Lazy Loading of images (From: "Johannes Fahrenkrug" <email@hidden>)
 >Re: Lazy Loading of images (From: "Kyle Sluder" <email@hidden>)

  • Prev by Date: Re: Problem with friend function and gcc 4.2 with
  • Next by Date: Re: NSImage and zooming PDFs vs. bitmaps
  • Previous by thread: Re: Lazy Loading of images
  • Next by thread: Control-dragging from menu item in MainMenu.nib to File's Owner object in MyDocument.nib
  • Index(es):
    • Date
    • Thread