is there anyway to turn on animation for gif images in an NSImageCell? The check box in IB is greyed out. I tried using the “setAnimates:” cocoa method, but that doesnt do anything. No errors or anything it just does nothing.
I used a WebView to accomplish showing an animated gif.
It gets loaded on awake from nib
Note that the code below expects the file to be in the app’s Resources folder
I heard a rumor that WebView is kinda new so I don’t know how far back this will work.
It works on OS X 10.4.11 for sure
on awake from nib theObject loadAnimation("animation.gif", "webview", "main") end awake from nib on loadAnimation(animationFileName, viewName, windowName) set myPath to (POSIX path of (path to me)) set fileURL to "file://" & myPath & "Contents/Resources/" & animationFileName try set webview to view viewName of window windowName set URLWithString to call method "URLWithString:" of class "NSURL" with parameter fileURL set requestWithURL to call method "requestWithURL:" of class "NSURLRequest" with parameter URLWithString set mainFrame to call method "mainFrame" of object webview call method "loadRequest:" of mainFrame with parameter requestWithURL on error theError --display dialog "Couldn't load web page:" & theError end try end loadAnimation
hmm…sorry i wasnt very clear in my first post. I want to do this in an NSImageCell in a table. and by the way you can display animated gifs in an image view, just check off the Animates check box. but for an image cell this box is greyed out.
i just upgraded to leopard, and in the new IB i can check off the animates button, but it still doesn’t animate the image cell.
“animates” and “setAnimates:” are methods of NSImageView. They are greyed out because they don’t apply to NSImageCell’s. It’s only displayed in IB because they’re likely reusing the same palette pane for both image views and cells. Something to think about… if you had a table view with hundreds or thousands of rows in it, all displaying a separate animated images, you could cause a machine to slow to a crawl. The only way I can see to do this, is to create your own subclass of NSCell, and handle all of your own drawing. That’s a big undertaking, one which I doubt you’re up for. Find another way.
Good point. I’ll probaby just leave it unanimated.