• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
RE: NSImageView in a PrefPane
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: NSImageView in a PrefPane


  • Subject: RE: NSImageView in a PrefPane
  • From: Joe Howard <email@hidden>
  • Date: Thu, 15 Nov 2001 02:12:58 -0800

Actually all you have to do is

filePath = [[self bundle] pathForResource:@"logo" ofType:@"tiff"];
logofile = [[NSImage alloc] initWithContentsOfFile:filePath]

[logo setImage:logofile];

It's a small change but I think it makes the code a little cleaner. The key is that NSPreferencePane has the method bundle which returns the path to your preference pane bundle.

Joe Howard



On Thursday, November 15, 2001, at 01:28 AM, email@hidden.
com wrote:

The problem you have is that the main bundle is not _yours_.
The main bundle is the system preferences application bundle...
You can do that with the following code (I'm sure it's not the best way) :

- (void) mainViewDidLoad
{
NSBundle *prefBundle;
NSString *pathForResource;
NSImage *logofile;

prefBundle = [NSBundle bundleForClass: [self class]];
pathForResource = [prefBundle pathForResource: @"logo" ofType:
@"tiff"];
logofile = [[NSImage alloc] initByReferencingFile: pathForResource];

// Probably, you can use your line of code, with a little change, instead
of mine :
// logofile = [NSImage imageNamed: pathForResource];
[logo setImage:logofile];
....
}

Regards
Yves


  • Prev by Date: Re: FSSpec for non-existant file?
  • Next by Date: Re: Notes on docs
  • Previous by thread: RE: NSImageView in a PrefPane
  • Next by thread: NSWindow / PB possible bugs
  • Index(es):
    • Date
    • Thread