You're creating an NSImage and pretending it's an NSImageView which
it's not. You'll need to create a new NSImageView and then the
NSImage and set the image as the imageview's image.
On May 30, 2009, at 8:27 AM, cocoa learner wrote:
Thanx Nick for your reply.But in my window I am not getting the
image I want
to display. Here is my code -
- (id) init
{
[super init];
NSLog(@"AppController::init : Setting the windows content");
NSBundle *myBundle = [NSBundle mainBundle];
if (myBundle == NULL)
{
NSLog(@"AppController::init : myBundle is NULL");
}
else
{
NSLog(@"AppController::init : myBundle is not NULL");
}
NSString *path = [myBundle pathForResource:@"winImg" ofType:@"png"];
NSLog(@"AppController::init : Image file path : %@", path);
NSImageView *winContent = [[NSImage alloc]
initWithContentsOfFile:path];
[ appWindow setContentView: winContent];
NSLog(@"AppController::init : The windows content has been set");
return self;
}
I can see all the logs. But not the image in back ground of my app
window.
Am I doing any thing wrong in this code?
Regards
Cocoa.learner.
On Tue, May 26, 2009 at 11:12 PM, Nick Zitzmann
<n...@chronosnet.com> wrote:
On May 26, 2009, at 11:04 AM, cocoa learner wrote:
How to draw background image in my app window?
You could change the window's content view using -setContentView:
to a view
that will draw a background image, such as NSImageView... Of
course, if you
have any other controls in the content view that is being replaced,
then
they'll be lost.
Nick Zitzmann
<http://www.chronosnet.com/>
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
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:
http://lists.apple.com/mailman/options/cocoa-dev/mikevann%40gmail.com
This email sent to mikev...@gmail.com
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to arch...@mail-archive.com