• 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
Accessing project images in IB Plugin
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Accessing project images in IB Plugin


  • Subject: Accessing project images in IB Plugin
  • From: Ricky Sharp <email@hidden>
  • Date: Sat, 3 Nov 2007 16:41:07 -0500

I'm having a bit of difficulty having my IB Plugin custom classes access images in the opened Xcode project.

When building my IB 2.x palettes, I had to write custom palette loading code to scan all the project images and load them in memory. This allowed me to have an NSString* ivar for say a custom view. In the view's drawRect:, I just needed to do:

NSImage* theImageToDraw = [NSImage imageNamed:[self myImageName]];


The IB Plug-In model will now populate the "Media" section of the "Library" window with all your project's images [1]. This is cool as it saves the custom loading code. However, I now have the following behavior:


* "Standard" controls such as NSImageView provides a combo-box in its inspector. The combo box contains a complete list of the names (sans extensions) of all images available. At design time, the image is also drawn in the image view. So far so good. Running in the simulator, which IMO should be where WYSIWYG kicks in, the image is not drawn. I believe this is because the Simulator doesn't have access to the images anymore; only the IB process itself has access to them.

* For my controls, I have no clue how to create a combo box like is used for NSImageView. Specifically, I don't know how to populate it with image names. This is no big deal as my control/view attributes inspector can still just use a plain text field. But, when I enter in a name, the name is indeed saved as the attribute but the "imageToDraw" variable in drawRect: is always nil.

I believe the solution here is to use the documentImageNamed: API. But this seems kinda clunky as I'd need to #ifdef code in my custom controls.

* The only solution I came up with to use my existing drawing code, and see the image at both design-time and in the simulator, is to add the images to the framework as part of the IB plugin. It works great, but that's going to be a maintenance nightmare.

Hmm...perhaps I could create a "graphics" framework for each of my projects that will make use of my IB Plugin. I can then mark the plugin to have a dependency upon those frameworks.

Anybody have a better idea of how to solve this? The goal here is to give me what I had in my IB 2.x palettes; true WYSIWYG editing at both design-time and in the simulator.


[1] Another shortcoming of the new IB is that if you have a folder of images in your Xcode project such that it uses a folder reference, those images are not accessible to IB.


___________________________________________________________
Ricky A. Sharp         mailto:email@hidden
Instant Interactive(tm)   http://www.instantinteractive.com

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: Problems wih xib
  • Next by Date: Re: Inline C functions in Xcode 3
  • Previous by thread: Re: Problems wih xib
  • Next by thread: Re: Accessing project images in IB Plugin
  • Index(es):
    • Date
    • Thread