On Sun, May 31, 2009 at 9:37 PM, Andy Lee <ag...@mac.com> wrote: > On May 31, 2009, at 8:51 AM, Uli Kusterer wrote: > > 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 had the same thought but when I tried it (and added a call to > setImageScaling:) the image didn't appear. I wonder what I'm doing wrong: > > - (void)awakeFromNib > { > NSLog(@"-[AppDelegate awakeFromNib]"); > > NSImage *whiteRoomImage = [NSImage imageNamed:@"WhiteRoom"]; > NSImageView *backgroundImageView = (NSImageView *)[_imageWindow > contentView]; > > NSLog(@"image: %@", whiteRoomImage); > NSLog(@"contentView: %@", [_imageWindow contentView]); > > [backgroundImageView setImageScaling:NSScaleToFit]; > [backgroundImageView setImage:whiteRoomImage]; > } > > Yet another approach would be to use IB to add an image view as a subview > of the window's content view, and use autoresizing to have it always fill > the content view. The benefit of this approach is that you can see the > background image in IB, so you can see what it looks like as you lay out its > subviews. >
This is same as what I had in the start of mail thread. [my first mail in this mail thread]. Regards Cocoa.learner > --Andy > > _______________________________________________ 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