Re: imageNamed cannot load an image
Re: imageNamed cannot load an image
- Subject: Re: imageNamed cannot load an image
- From: Michael Watson <email@hidden>
- Date: Wed, 21 Mar 2007 17:27:49 -0400
Is the image actually part of a copy files build phase? Does it show
up in your app package when built?
--
On 21 Mar, 2007, at 17:24, Artemiy Pavlov wrote:
On 21 Mar 2007, at 10:46 PM, Christopher Hickman wrote:
NSImage *BackgroundImage = [NSImage
imageNamed:@"SpaceOscillator"];
Try using @"SpaceOscillator.png"
From
http://developer.apple.com/documentation/Cocoa/Reference/
ApplicationKit/Clas
ses/NSImage_Class/Reference/Reference.html:
When looking for files in the application bundle, it is better
(but not
required) to include the filename extension in the name parameter.
When
naming an image with the setName: method, it is also convention
not to
include filename extensions in the names you specify. That way,
you can
easily distinguish between images you have named explicitly and
those you
want to load from the application's bundle.
Thanks, I just tried this:
NSString* BackgroundImageName = [[NSBundle mainBundle]
pathForResource:@"SpaceOscillator.png" ofType:@"PNG"];
NSImage* BackgroundImage = [[NSImage alloc]
initWithContentsOfFile:BackgroundImageName];
and this:
NSString* BackgroundImageName = [[NSBundle mainBundle]
pathForResource:@"SpaceOscillator" ofType:@"PNG"];
NSImage* BackgroundImage = [[NSImage alloc]
initWithContentsOfFile:BackgroundImageName];
And in both cases BackgroundImage is nil...
Are there any extra steps except for dragging an image file into
the "Resources" in the XCode project, i.e.:
<Picture 1.png>
The image shows up in the IB as "SpaceOscillator" and I can paste
it into the view, it will work, but I want to render it as a
background.
Thanks very much,
Artemiy_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
40bungie.org
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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