How do I remove (or blank out) the image that is currently displayed in an image view?
I assume, you’re talking about Xcode.
In the Xcode help > AppleScript search for load image and click Application Suite (first result).
There is a description with examples
the documention says only how to free a loaded image from memory, but if the image is currently being displayed in an image view, the view will not be affected. It states no where how to remove an image from a view. Ive spent the better paprt of today seraching the docs and the web for instructions or examples on how to actually remove an image from an image view.
And, while, yse, i am developing in xcode, I am actually working on an applescript application, and i what I need to know is how to remove an image object from an image view object using code.
Moving to AS Studio & Xcode…
delete image of image view "whatever" of window "whatever"
That was the very first thing I tried. long before i even posted. When I try to delete the image, I get the following error
NSReceiverEvaluationScriptError: 4 (1)
this is the line of code i am using
delete the image of image view "artwork file" of tab view item "Movie" of tab view "mainTabView" of window "theMainWindow"
I just tried that in a new project, and it works fine. That error usually means that the object is not being properly referenced; Are you certain there are no typos or missing objects? (A box, perhaps, or maybe a scroll view.)
I copied that reference line from a different working bit of code elsewhere in my project. Perhaps something else is an issue here. perhaps im trying to delete an image that currently doesnt exist. how would I check to make sure there is, in fact, an image currently being displayed?
as Bruce said, NSReceiverEvaluationScriptError is probably an error in Interface Builder.
Have you selected and enabled the right script at the bottom of the Inspector window > AppleScript?
yes. I am certain. the event is firing just fine, as all my other code is accomplished.
basically what I am trying to do, is erase the contents of every item in all views of a tab view other the the currently visible tab view.
I can clear all of them just fine, except for the contents of the image view. I have triple checked the spelling of the object name an all that jazz.
It still works for me when there isn’t an image currently being displayed.
Is the pasted line inside a tell block?
it was pasted into a tell block when i am sending the tells to the tab i am currently clearing
however, I have also tried it with simply:
tell tab view item 1 of tab view 1 of window 1 --do some other stuff delete image of image view "artwork file" --do some other stuff end tell
for example, I have this bit of code contained within a tell block to load an image into the current view which works
tell tab view item "movieTab" of tab view "mainTabView" of window "theMainWindow" ---some stuff before this (just filling the contents of text fields set image of image view "artwork file" to load image (contents of the data cell "artwork file" of the selectedRow) end tell
this almost identical tell block works all the way up to the delete image line the only difference in the blocks is that instead of entering data into text views and such, im removing them
tell tab view item "tvShowTab" of tab view "mainTabView" of window "theMainWindow" ---some stuff before this (just filling the contents of text fields delete image of image view "artwork file" end tell
this code get executed after both a drop event and a tab view change event.
before, when I dropped an item into the drop area, i would get an error at the delete image line.
after a few changes, I can no do one drop event without getting an error, subsequent drop events cause the application to crash and reload and a tab change causes an error dialog to pop up. Again, all of this goes away when i outcomment the delete image line.