Re: How to draw background image in my app window
Re: How to draw background image in my app window
- Subject: Re: How to draw background image in my app window
- From: Uli Kusterer <email@hidden>
- Date: Sun, 31 May 2009 14:51:14 +0200
Am 30.05.2009 um 19:45 schrieb cocoa learner:
Yah Andy and Michael you all were right. But still I have some
problem.1>.
While resizing the window Image is not getting resized.
You could probably fix that using setImageScaling: on the image view.
2>. My controls (NSButton and NSTextField) are not visible after the
awakeFromNib call.
You are replacing the window's content view with a new view. That
means that the entire content view and all its subviews get removed.
You may want to loop over the subviews of the previous content view
and move them all to your image view.
Another approach would be to try changing the class of your content
view in Interface builder. Simply click the background of the window,
that should show the content view in the inspector. Go to the
"Identity" tab and change the class to NSImageView. Then you can
probably just do
[(NSImageView*)[myWindow contentView] setImage: [[[NSImage alloc]
initWithContentsOfFile: path] autorelease]];
I haven't actually tried this, but I know you can select the content
view that way since Interface Builder 3.x, and I know you can change
classes of objects that way, so this should work.
NSString *path = [myBundle pathForResource:@"winImg" ofType:@"png"];
NSLog(@"AppController::init : Image file path : %@", path);
// winImageView is a data member of this class
winImageView = [[NSImageView alloc] init];
[winImageView setImage: [[NSImage alloc] initWithContentsOfFile:
path]];
Are you using garbage collection? If not, you are leaking the image
and the image view here. In that case, you may want to re-read Apple's
memory-management documentation, which describes which things need to
be released and which ones don't.
Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
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