• 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: Images in custom IB palette
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Images in custom IB palette


  • Subject: Re: Images in custom IB palette
  • From: Christopher Skogen <email@hidden>
  • Date: Wed, 22 Sep 2004 03:36:57 -0500

ricky,

i was scanning the archives and i found your issue, but no responses. i'm having the same problem as we speak. did you ever find anything out re: this? i think it has something to do with what "imageNamed" thinks is the current bundle, but i'm not sure how to realize that my view is running in IB. (or if i even need to).

any help you can provide would be appreciated,

chris skogen
gizmolabs. inc.

On Sep 4, 2004, at 7:20 AM, Ricky Sharp wrote:

Any takers on this issue? No problem if not. I thought I'd ask again before I file a DTS incident later this weekend.

Original e-mail follows.

Thanks,

Rick

On Sep 1, 2004, at 1:37 PM, Ricky Sharp wrote:

In iB, I'm having trouble seeing images in my custom controls.

I have a properly built and installed IB palette that currently provides a custom button (relevant parts derived from NSCell and NSControl). Four of the fields on the button's inspector are text fields where I can type in the name of the image file to use for a particular state.

Now then, I created a new Cocoa doc-based app and added several PDF files to the project. When I open that project's nib in IB, the images tab is filled with all my PDFs. So far so good.

But when I drag my custom button to the main window, bring up the inspector, and fill in the image names I want it to use, the displayed control never loads the images. This is also true when I test the interface. Note that all appropriate outlets actions are indeed wired correctly.

But if I return to Xcode and just build & run the app, the images do load correctly.

Given an NSString (imageName) that contains the name of the image, here's the logic behind loading that image:

NSBundle* imageBundle = [NSBundle bundleForClass:[IIButtonCell class]];
NSString* imagePath = [imageBundle pathForResource:imageName ofType:@"pdf"];
NSImage* image = [[NSImage alloc] initWithContentsOfFile:imagePath];



I also tried just using the main bundle rather than bundleForClass, but that made no difference.



Of all the IB palette sample code I've found, there's none that deal with custom images like this. Some, like ClockControl, embed an image that is always used and exported by the nib. Here, I want to kinda do the opposite. Use images that will ultimately be stored next to the nib.


I know this is possible because the inspector for NSImageView allows you to enter the image name. I was able to have such a control display the appropriate pdf while in IB.

Some details:

Xcode 1.5 on Mac OS X 10.3.5
Baseline of app is 10.3
Nib format saved in 10.2 and later.
___________________________________________________________
Ricky A. Sharp mailto:email@hidden
Instant Interactive(tm) http://www.instantinteractive.com
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.




_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Images in custom IB palette
      • From: Ricky Sharp <email@hidden>
  • Prev by Date: Re: NSAppKitVersionNumber for 10.3.0?
  • Next by Date: Program Crash
  • Previous by thread: Re: scrollToPoint vs scrollRectToVisible
  • Next by thread: Re: Images in custom IB palette
  • Index(es):
    • Date
    • Thread